Skip to content
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
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@
- fix: `RTDC_Dict` did not allow "file" basins, because the class
attribute `_local_basins_allowed` was shadowed by the instance
attribute set in `RTDCBase.__init__` (#421)
- fix: `Export.fcs` and `Export.tsv` added the "dclab version" key to
the `meta_data` dictionary passed by the caller (#422)
0.74.0
- fix: CLI commands compress, condense, join, and repack deleted the
input file if it was also given as the output path
Expand Down
8 changes: 4 additions & 4 deletions dclab/rtdc_dataset/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ def fcs(self,
Due to incompatibility with the .fcs file format, events that have
a NaN value in any of the exported features are not exported.
"""
if meta_data is None:
meta_data = {}
# copy to not modify the dictionary passed by the caller
meta_data = dict(meta_data) if meta_data is not None else {}
if not FCSWRITE_AVAILABLE:
raise ModuleNotFoundError(
"Package `fcswrite` required for fcs export!")
Expand Down Expand Up @@ -669,8 +669,8 @@ def tsv(self,
1 for monitoring progress and a string describing what is being
done.
"""
if meta_data is None:
meta_data = {}
# copy to not modify the dictionary passed by the caller
meta_data = dict(meta_data) if meta_data is not None else {}
features = [c.lower() for c in features]
features = sorted(set(features))
path = pathlib.Path(path)
Expand Down
11 changes: 11 additions & 0 deletions tests/test_rtdc_export_fcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,14 @@ def test_fcs_not_filtered():
edest = tempfile.mkdtemp()
f1 = join(edest, "test.tsv")
ds.export.fcs(f1, keys, filtered=False)


def test_fcs_export_meta_data_not_modified(tmp_path):
"""The `meta_data` dictionary of the caller must not be modified"""
pytest.importorskip("fcswrite")
keys = ["area_um", "deform"]
ddict = example_data_dict(size=222, keys=keys)
ds = dclab.new_dataset(ddict)
meta_data = {"sample": "test"}
ds.export.fcs(tmp_path / "test.fcs", keys, meta_data=meta_data)
assert meta_data == {"sample": "test"}
10 changes: 10 additions & 0 deletions tests/test_rtdc_export_tsv.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,13 @@ def test_tsv_not_filtered(tmp_path):

f1 = tmp_path / "test.tsv"
ds.export.tsv(f1, keys, filtered=False)


def test_tsv_export_meta_data_not_modified(tmp_path):
"""The `meta_data` dictionary of the caller must not be modified"""
keys = ["area_um", "deform"]
ddict = example_data_dict(size=222, keys=keys)
ds = dclab.new_dataset(ddict)
meta_data = {"sample": "test"}
ds.export.tsv(tmp_path / "test.tsv", keys, meta_data=meta_data)
assert meta_data == {"sample": "test"}
Loading