Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bugs with frame recording and temperature in morpher. #135

Merged
merged 1 commit into from
Jun 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/data_morph/morpher.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ def morph(
)
frame_number = record_frames(
data=morphed_data,
count=freeze_for,
count=max(freeze_for, 1),
frame_number=0,
)

Expand All @@ -454,7 +454,7 @@ def _tweening(frame, *, min_value, max_value): # numpydoc ignore=PR01,RT01
get_current_temp = partial(
_tweening,
min_value=min_temp,
max_value=min_temp,
max_value=max_temp,
)
get_current_shake = partial(
_tweening,
Expand Down
22 changes: 9 additions & 13 deletions tests/test_morpher.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,28 +200,24 @@ def test_saving_data(self, tmp_path):
in_notebook=False,
)

frame_config = {
'iterations': iterations,
'ramp_in': False,
'ramp_out': False,
'freeze_for': 0,
}
frames = morpher._select_frames(**frame_config)

morphed_data = morpher.morph(
start_shape=dataset,
target_shape=shape_factory.generate_shape(target_shape),
**frame_config,
iterations=iterations,
ramp_in=False,
ramp_out=False,
freeze_for=0,
)

# we don't save the data for the first frame since it is in the input data
assert not (tmp_path / f'{base_file_name}-data-000.csv').is_file()

# make sure we have the correct number of files
for kind, count in zip(
['png', 'csv'], [num_frames - 1, num_frames - frames.count(0)]
):
assert len(glob.glob(str(tmp_path / f'{base_file_name}*.{kind}'))) == count
for kind in ['png', 'csv']:
assert (
len(glob.glob(str(tmp_path / f'{base_file_name}*.{kind}')))
== num_frames
)

# at the final frame, we have the output data
assert_frame_equal(
Expand Down