Skip to content

Commit b99019d

Browse files
committed
#560: object: add index from json if it exists to object
1 parent c7130e7 commit b99019d

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

src/lbaf/IO/lbsVTDataReader.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,8 @@ def _populate_rank(self, phase_id: int, rank_id: int) -> Tuple[Rank,dict]:
294294
load=task_load,
295295
user_defined=task_user_defined,
296296
subphases=subphases,
297-
collection_id=collection_id)
297+
collection_id=collection_id,
298+
index=index)
298299

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

307308
# Add dict of currently unused parameters
308309
unused_params = {}
309-
if index is not None:
310-
unused_params["index"] = index
311310
if objgroup_id is not None:
312311
unused_params["objgroup_id"] = objgroup_id
313312
o.set_unused_params(unused_params)

src/lbaf/IO/lbsVTDataWriter.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ def __create_tasks(self, rank_id, objects, migratable):
123123
if o.get_collection_id() is not None:
124124
task_data["entity"]["collection_id"] = o.get_collection_id()
125125

126+
if o.get_index() is not None:
127+
task_data["entity"]["index"] = o.get_index()
128+
126129
if unused_params:
127130
task_data["entity"].update(unused_params)
128131

src/lbaf/Model/lbsObject.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class Object:
5858
:arg user_defined: user defined data dict, defaults to None
5959
:arg subphases: list of subphases, defaults to None
6060
:arg collection_id: collection id (required for migratable objects)
61+
:arg index: the n-dimensional index for an object that belongs to a collection
6162
"""
6263

6364
def __init__(
@@ -70,7 +71,8 @@ def __init__(
7071
comm: Optional[ObjectCommunicator]=None,
7172
user_defined: dict=None,
7273
subphases: list=None,
73-
collection_id: Optional[int] = None):
74+
collection_id: Optional[int] = None,
75+
index: Optional[list] = None):
7476

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

156+
if index is not None:
157+
self.__index = index
158+
154159
def __repr__(self):
155160
return f"Object id: {self.get_id()}, load: {self.__load}"
156161

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

182+
def get_index(self) -> Optional[list]:
183+
"""Return the object's index."""
184+
return self.__index
185+
186+
def set_index(self, index: Optional[list]):
187+
"""Set an object's index."""
188+
self.__index = index
189+
177190
def set_load(self, load: float):
178191
""" Set object load."""
179192
self.__load = load

0 commit comments

Comments
 (0)