Skip to content

Commit

Permalink
fix bad coordinates in history.retrieve
Browse files Browse the repository at this point in the history
  • Loading branch information
glyg committed Nov 18, 2021
1 parent c104056 commit 7691273
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
29 changes: 25 additions & 4 deletions tests/core/test_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,12 @@ def test_historyHDF5_retrieve():
def test_historyHDF5_save_every():
sheet = Sheet("3", *three_faces_sheet())

history = HistoryHdf5(sheet, save_every=2, dt=1, hf5file="out.hf5",)
history = HistoryHdf5(
sheet,
save_every=2,
dt=1,
hf5file="out.hf5",
)

for element in sheet.datasets:
assert sheet.datasets[element].shape[0] == history.datasets[element].shape[0]
Expand Down Expand Up @@ -214,7 +219,10 @@ def test_historyHDF5_save_every():
def test_historyHDF5_itemsize():
sheet = Sheet("3", *three_faces_sheet())
sheet.vert_df["segment"] = "apical"
history = HistoryHdf5(sheet, hf5file="out.hf5",)
history = HistoryHdf5(
sheet,
hf5file="out.hf5",
)

for element in sheet.datasets:
assert sheet.datasets[element].shape[0] == history.datasets[element].shape[0]
Expand Down Expand Up @@ -280,6 +288,13 @@ def test_historyHDF5_from_archive():
os.remove("test.hf5")


def test_retrieve_coords():
sheet = Sheet("3", *three_faces_sheet())
history = History(sheet)
history.record()
assert history.retrieve(0).coords == sheet.coords


def test_to_and_from_archive():

sheet = Sheet("3", *three_faces_sheet())
Expand All @@ -298,7 +313,10 @@ def test_to_and_from_archive():

def test_unsaved_col():
sheet = Sheet("3", *three_faces_sheet())
history = HistoryHdf5(sheet, hf5file="test.hf5",)
history = HistoryHdf5(
sheet,
hf5file="test.hf5",
)
history.record()
history.record()
sheet.face_df["new_col"] = 0
Expand All @@ -309,7 +327,10 @@ def test_unsaved_col():

def test_change_col_types():
sheet = Sheet("3", *three_faces_sheet())
history = HistoryHdf5(sheet, hf5file="test.hf5",)
history = HistoryHdf5(
sheet,
hf5file="test.hf5",
)
history.record()
history.record()
sheet.face_df["z"] = "abc"
Expand Down
1 change: 1 addition & 0 deletions tyssue/core/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ def retrieve(self, time):
sheet = type(self.sheet)(
f"{self.sheet.identifier}_{time:04.3f}", sheet_datasets, self.sheet.specs
)
sheet.coords = self.sheet.coords
sheet.edge_df.index.rename("edge", inplace=True)
return sheet

Expand Down

0 comments on commit 7691273

Please sign in to comment.