From e36d295af40451553eca2f7ce529b462511ba3e5 Mon Sep 17 00:00:00 2001 From: Jon Mease Date: Tue, 3 Sep 2019 11:10:59 -0400 Subject: [PATCH] Make operation_kwargs private to the Histogram class --- holoviews/element/chart.py | 17 ++--------------- holoviews/operation/element.py | 4 ++-- holoviews/tests/operation/testoperation.py | 6 +++--- 3 files changed, 7 insertions(+), 20 deletions(-) diff --git a/holoviews/element/chart.py b/holoviews/element/chart.py index cada4c9a09..bd75381a68 100644 --- a/holoviews/element/chart.py +++ b/holoviews/element/chart.py @@ -182,27 +182,14 @@ def __init__(self, data, edges=None, **params): elif isinstance(data, tuple) and len(data) == 2 and len(data[0])+1 == len(data[1]): data = data[::-1] - self._operation_kwargs = params.pop('operation_kwargs', None) + self._operation_kwargs = params.pop('_operation_kwargs', None) super(Histogram, self).__init__(data, **params) - @property - def operation_kwargs(self): - """ - If Histogram was generated by the holoviews.operation.histogram - operation, this property contains a dictionary of keyword-value - arguments that can be used with the histogram operation to regenerate - this histogram from the same input dataset. - - If Histogram was created directly using the constructor, property - will be None. - """ - return self._operation_kwargs - def clone(self, *args, **kwargs): return super(Histogram, self).clone( *args, - operation_kwargs=copy.deepcopy(self.operation_kwargs), + _operation_kwargs=copy.deepcopy(self._operation_kwargs), **kwargs ) diff --git a/holoviews/operation/element.py b/holoviews/operation/element.py index 0cf6ab07c1..2132cda351 100644 --- a/holoviews/operation/element.py +++ b/holoviews/operation/element.py @@ -663,10 +663,10 @@ def _process(self, element, key=None): # from the same data set, but we can also generate a histogram using # a different dataset that will share the exact same bins. exclusions = {'log', 'bin_range', 'num_bins'} - params['operation_kwargs'] = { + params['_operation_kwargs'] = { k: v for k, v in self.p.items() if k not in exclusions } - params['operation_kwargs']['bins'] = list(edges) + params['_operation_kwargs']['bins'] = list(edges) return Histogram((edges, hist), kdims=[element.get_dimension(selected_dim)], label=element.label, **params) diff --git a/holoviews/tests/operation/testoperation.py b/holoviews/tests/operation/testoperation.py index 526b249fa0..399172fa15 100644 --- a/holoviews/tests/operation/testoperation.py +++ b/holoviews/tests/operation/testoperation.py @@ -167,7 +167,7 @@ def test_histogram_operation_kwargs(self): # Check operation kwargs for histogram generated with operation self.assertEqual( - op_hist.operation_kwargs, + op_hist._operation_kwargs, {'dimension': 'y', 'normed': False, 'dynamic': False, @@ -176,7 +176,7 @@ def test_histogram_operation_kwargs(self): # Test that operation_kwargs is preserved through clone self.assertEqual( - op_hist.clone().operation_kwargs, + op_hist.clone()._operation_kwargs, {'dimension': 'y', 'normed': False, 'dynamic': False, @@ -185,7 +185,7 @@ def test_histogram_operation_kwargs(self): # Check that operation kwargs is None for histogram generated directly # from the Histogram constructor - self.assertIsNone(hist.operation_kwargs) + self.assertIsNone(hist._operation_kwargs) @da_skip def test_dataset_histogram_dask(self):