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
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@
`KernelDensityEstimationForEmtpyArrayWarning` to
`KernelDensityEstimationForEmptyArrayWarning` (the old names are
deprecated aliases) (#420)
- 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)
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
7 changes: 5 additions & 2 deletions dclab/rtdc_dataset/fmt_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ def shape(self):


class RTDC_Dict(RTDCBase):
_local_basins_allowed = True

def __init__(self, ddict, *args, **kwargs):
"""Dictionary-based RT-DC dataset

Expand All @@ -61,6 +59,11 @@ def __init__(self, ddict, *args, **kwargs):

super().__init__(*args, **kwargs)

# The data are in memory on the user's computer, so local basins
# are allowed (must be set after `RTDCBase.__init__`, which sets
# this instance attribute to False).
self._local_basins_allowed = True

t = time.localtime()

# Get an identifying string
Expand Down
28 changes: 27 additions & 1 deletion tests/test_rtdc_fmt_dict.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
"""Test dictionary format"""
import warnings

import numpy as np

from dclab import new_dataset
from dclab import new_dataset, RTDCWriter
from dclab.rtdc_dataset.core import LocalBasinForbiddenWarning

import pytest

Expand Down Expand Up @@ -33,6 +36,29 @@ def test_image_not_available():
assert "image" not in ds


def test_local_basins_allowed(tmp_path):
"""RTDC_Dict allows "file" basins (data are on the user's computer)"""
path_basin = tmp_path / "basin.rtdc"
with RTDCWriter(path_basin) as hw:
hw.store_metadata({"experiment": {"sample": "basin",
"run index": 1}})
hw.store_feature("deform", np.linspace(0.01, 0.1, 10))
ddict = {"area_um": np.linspace(10, 100, 10)}
ds = new_dataset(ddict)
bdict = {"name": "local file",
"type": "file",
"format": "hdf5",
"paths": [str(path_basin)],
"features": ["deform"],
}
# RTDC_Dict does not define basins itself
ds.basins_get_dicts = lambda: [bdict]
with warnings.catch_warnings():
warnings.simplefilter("error", LocalBasinForbiddenWarning)
assert "deform" in ds
assert np.allclose(ds["deform"], np.linspace(0.01, 0.1, 10))


def test_min_max_update():
ddict = example_data_dict(size=67, keys=["area_um", "deform"])
ds = new_dataset(ddict)
Expand Down
Loading