Skip to content

Commit

Permalink
tests: add test for writing all-nan data (close #242)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Jan 12, 2024
1 parent df4798b commit 6fef6c1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
0.57.1
- fix: RTDCWriter.rectify_metadata fails when image feature is empty
- fix: Handle empty write requests in export.hdf5 and RTDCWriter (#242)
- fix: handle empty write requests in export.hdf5 and RTDCWriter (#242)
- tests: add test for writing all-nan data (#242)
- docs: improve documentation of hierarchy child mapper
0.57.0
- fix: integer overflow in downsample_grid
Expand Down
13 changes: 13 additions & 0 deletions tests/test_rtdc_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,19 @@ def test_mode():
assert len(events2["area_um"]) == len(data["area_um"])


def test_nan_array():
rtdc_file = tempfile.mktemp(suffix=".rtdc",
prefix="dclab_test_error_")
with RTDCWriter(rtdc_file) as hw:
with pytest.warns(RuntimeWarning) as record:
hw.store_feature("deform", np.full(100, np.nan))

assert len(record) == 3
assert record[0].message.args[0] == "All-NaN axis encountered"
assert record[1].message.args[0] == "All-NaN axis encountered"
assert record[2].message.args[0] == "Mean of empty slice"


@pytest.mark.filterwarnings(
"ignore::dclab.rtdc_dataset.config.WrongConfigurationTypeWarning")
def test_non_scalar_bad_shape():
Expand Down

0 comments on commit 6fef6c1

Please sign in to comment.