Skip to content

Commit

Permalink
enh: lazily load logs and tables in fmt_hierarchy
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Apr 4, 2024
1 parent 0796e50 commit 7ebd834
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
0.58.2
- fix: KeyError when iteration over DCOR logs or tables
- enh: lazily load logs and tables in `fmt_hierarchy`
0.58.1
- fix: exporting with basins from a hierarchy child did not write a
basin derived from the hierarchy root parent
Expand Down
30 changes: 28 additions & 2 deletions dclab/rtdc_dataset/fmt_hierarchy/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ def __init__(self, hparent, apply_filter=True, *args, **kwargs):

self.path = hparent.path
self.title = hparent.title + "_child"
self.logs = hparent.logs
self.tables = hparent.tables
self._logs = None # lazily-loaded
self._tables = None # lazily-loaded

self._events = {}

Expand Down Expand Up @@ -191,6 +191,32 @@ def hash(self):
dhash = hashobj(hph + hpfilt)
return dhash

@property
def logs(self):
if self._logs is None:
self._logs = self.hparent.logs
return self._logs

@logs.setter
def logs(self, value):
# to support setting `self.logs = {}` in RTDCBase
if value:
raise ValueError(
"Setting actual logs not supported for RTDC_Hierarchy")

@property
def tables(self):
if self._tables is None:
self._tables = self.hparent.tables
return self._tables

@tables.setter
def tables(self, value):
# to support setting `self.tables = {}` in RTDCBase
if value:
raise ValueError(
"Setting actual tables not supported for RTDC_Hierarchy")

def apply_filter(self, *args, **kwargs):
"""Overridden `apply_filter` to perform tasks for hierarchy child"""
if self._ds_filter is not None:
Expand Down

0 comments on commit 7ebd834

Please sign in to comment.