Skip to content

Commit

Permalink
TrackInfo index change to relative to existing data
Browse files Browse the repository at this point in the history
  • Loading branch information
sctop committed Jan 20, 2024
1 parent a55926e commit 21d71f9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion data
12 changes: 8 additions & 4 deletions data_model/actual_data/track.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,11 +482,15 @@ def get_instance(cls, instance_id):
return super().get_instance(instance_id)

def _get_instance_offset(self, offset: int):
t = self.instance_id.split("_")
no = int(t[1]) + offset
keys = list(self._instance.keys())
curr_index = keys.index(self.instance_id)

if curr_index + offset < 0:
return None

try:
return self._instance["_".join([t[0], str(no)])]
except KeyError:
return self._instance[self._instance[curr_index + offset]]
except KeyError or IndexError:
return None

def set_stat(self, stat_name, value):
Expand Down

0 comments on commit 21d71f9

Please sign in to comment.