Skip to content

Commit

Permalink
Add __getstate__ / __setstate__ method to dim to fix RecursionError (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jonmmease committed Sep 1, 2020
1 parent d584e1b commit 5798606
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
8 changes: 7 additions & 1 deletion holoviews/tests/util/testtransform.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from __future__ import division

import sys
import pickle

from collections import OrderedDict
from unittest import skipIf
Expand Down Expand Up @@ -481,7 +482,7 @@ def test_xarray_quantile_method(self):
def test_xarray_roll_method(self):
expr = dim('z').xr.roll({'x': 1}, roll_coords=False)
self.assert_apply_xarray(expr, self.dataset_xarray.data.z.roll({'x': 1}, roll_coords=False))

@xr_skip
@py2_skip
def test_xarray_coarsen_method(self):
Expand Down Expand Up @@ -513,3 +514,8 @@ def test_dynamic_kwarg(self):
self.assert_apply(expr, np.round(self.linear_floats, 1))
p.a = 2
self.assert_apply(expr, np.round(self.linear_floats, 2))

def test_pickle(self):
expr = (((dim('float')-2)*3)**2)
expr2 = pickle.loads(pickle.dumps(expr))
self.assertEqual(expr, expr2)
6 changes: 6 additions & 0 deletions holoviews/util/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,12 @@ def __init__(self, obj, *args, **kwargs):
'reverse': kwargs.pop('reverse', False)}]
self.ops = ops

def __getstate__(self):
return self.__dict__

def __setstate__(self, state):
self.__dict__.update(state)

@property
def _current_accessor(self):
if self.ops and self.ops[-1]['kwargs'].get('accessor'):
Expand Down

0 comments on commit 5798606

Please sign in to comment.