Skip to content

Commit

Permalink
#560: object: add index from json if it exists to object
Browse files Browse the repository at this point in the history
  • Loading branch information
lifflander committed Nov 11, 2024
1 parent c7130e7 commit b99019d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/lbaf/IO/lbsVTDataReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,8 @@ def _populate_rank(self, phase_id: int, rank_id: int) -> Tuple[Rank,dict]:
load=task_load,
user_defined=task_user_defined,
subphases=subphases,
collection_id=collection_id)
collection_id=collection_id,
index=index)

# Update shared block information as needed
if (shared_id := task_user_defined.get("shared_id", -1)) > -1:
Expand All @@ -306,8 +307,6 @@ def _populate_rank(self, phase_id: int, rank_id: int) -> Tuple[Rank,dict]:

# Add dict of currently unused parameters
unused_params = {}
if index is not None:
unused_params["index"] = index
if objgroup_id is not None:
unused_params["objgroup_id"] = objgroup_id
o.set_unused_params(unused_params)
Expand Down
3 changes: 3 additions & 0 deletions src/lbaf/IO/lbsVTDataWriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ def __create_tasks(self, rank_id, objects, migratable):
if o.get_collection_id() is not None:
task_data["entity"]["collection_id"] = o.get_collection_id()

if o.get_index() is not None:
task_data["entity"]["index"] = o.get_index()

if unused_params:
task_data["entity"].update(unused_params)

Expand Down
15 changes: 14 additions & 1 deletion src/lbaf/Model/lbsObject.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class Object:
:arg user_defined: user defined data dict, defaults to None
:arg subphases: list of subphases, defaults to None
:arg collection_id: collection id (required for migratable objects)
:arg index: the n-dimensional index for an object that belongs to a collection
"""

def __init__(

Check notice on line 64 in src/lbaf/Model/lbsObject.py

View workflow job for this annotation

GitHub Actions / code-quality (ubuntu-latest, 3.8)

Too many arguments (11/7) (too-many-arguments)

Check notice on line 64 in src/lbaf/Model/lbsObject.py

View workflow job for this annotation

GitHub Actions / code-quality (ubuntu-latest, 3.8)

Too many branches (15/12) (too-many-branches)
Expand All @@ -70,7 +71,8 @@ def __init__(
comm: Optional[ObjectCommunicator]=None,
user_defined: dict=None,
subphases: list=None,
collection_id: Optional[int] = None):
collection_id: Optional[int] = None,
index: Optional[list] = None):

# Check that id is provided as defined in LBDatafile schema
if packed_id is None and seq_id is None:
Expand Down Expand Up @@ -151,6 +153,9 @@ def __init__(
else:
raise TypeError(f"subphases: {subphases} is of type {type(subphases)} but must be <class 'list'>")

if index is not None:
self.__index = index

Check warning on line 157 in src/lbaf/Model/lbsObject.py

View workflow job for this annotation

GitHub Actions / code-quality (ubuntu-latest, 3.8)

Bad indentation. Found 11 spaces, expected 12 (bad-indentation)

def __repr__(self):
return f"Object id: {self.get_id()}, load: {self.__load}"

Expand All @@ -174,6 +179,14 @@ def set_collection_id(self, collection_id: Optional[int]):
""" Set object collection ID (required for migratable objects)."""
self.__collection_id = collection_id

def get_index(self) -> Optional[list]:
"""Return the object's index."""
return self.__index

def set_index(self, index: Optional[list]):
"""Set an object's index."""
self.__index = index

def set_load(self, load: float):
""" Set object load."""
self.__load = load
Expand Down

0 comments on commit b99019d

Please sign in to comment.