Skip to content

Commit

Permalink
Further fixes to optimize garbage collection (#4377)
Browse files Browse the repository at this point in the history
* Make Dataset clone on selection

* Further improvements for .dataset handling
  • Loading branch information
philippjfr authored Apr 10, 2020
1 parent 918758c commit 7499b42
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
11 changes: 4 additions & 7 deletions holoviews/core/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,8 @@ def __init__(self, data, kdims=None, vdims=None, **kwargs):
else:
self._dataset = Dataset(input_data, dataset=None, pipeline=None,
transforms=None, _validate_vdims=False)
if hasattr(self, '_binned'):
self._dataset._binned = self._binned

@property
def redim(self):
Expand All @@ -390,7 +392,8 @@ def dataset(self):
if type(self) is Dataset:
return self
datatype = list(util.unique_iterator(self.datatype+Dataset.datatype))
dataset = Dataset(self, _validate_vdims=False, datatype=datatype)
dataset = Dataset(self, dataset=None, pipeline=None, transforms=None,
_validate_vdims=False, datatype=datatype)
if hasattr(self, '_binned'):
dataset._binned = self._binned
return dataset
Expand Down Expand Up @@ -1161,12 +1164,6 @@ def clone(self, data=None, shared_data=True, new_type=None, link=True,
data = self
if link:
overrides['plot_id'] = self._plot_id

if 'dataset' not in overrides:
overrides['dataset'] = self.dataset

if 'pipeline' not in overrides:
overrides['pipeline'] = self._pipeline
elif self._in_method:
if 'dataset' not in overrides:
overrides['dataset'] = self.dataset
Expand Down
1 change: 1 addition & 0 deletions holoviews/selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ def _select(element, selection_expr):
mask = selection_expr.apply(dataset, compute=False, keep_index=True, strict=True)
selection = dataset.select(selection_mask=mask)
element = element.pipeline(selection)
element._dataset = dataset
except KeyError as e:
key_error = str(e).replace('"', '').replace('.', '')
raise CallbackError("linked_selection aborted because it could not "
Expand Down

0 comments on commit 7499b42

Please sign in to comment.