error creating a second Plots() instance: triggers trait error (strange interdependence?)
To reproduce:
Start fresh kernel, run this code:
import numpy as np
import xarray
from datacube import Plots
x = np.linspace(-5,5,100)
X,Y = np.meshgrid(x,x)
Z = X*Y*np.exp(-X**2-Y**2)
# Needs to have 3 dimensions
Z = Z[np.newaxis, :,:]
d = xarray.DataArray(Z, name='Z')
Create a plot, works fine:
p = Plots()
p.load_xarray(d)
p.plot_image()
But this then triggers an error:
p2 = Plots()
p2.load_xarray(d)
p2.plot_image()
TraitError Traceback (most recent call last)
<ipython-input-3-a6e7deda6b26> in <module>
----> 1 p2 = Plots()
2 p2.load_xarray(d)
3 p2.plot_image()
~/anaconda3/envs/myenv/lib/python3.7/site-packages/traitlets/traitlets.py in __new__(cls, *args, **kwargs)
956 else:
957 inst = new_meth(cls, *args, **kwargs)
--> 958 inst.setup_instance(*args, **kwargs)
959 return inst
960
~/anaconda3/envs/myenv/lib/python3.7/site-packages/traitlets/traitlets.py in setup_instance(self, *args, **kwargs)
984 self._trait_notifiers = {}
985 self._trait_validators = {}
--> 986 super(HasTraits, self).setup_instance(*args, **kwargs)
987
988 def __init__(self, *args, **kwargs):
~/anaconda3/envs/myenv/lib/python3.7/site-packages/traitlets/traitlets.py in setup_instance(self, *args, **kwargs)
975 else:
976 if isinstance(value, BaseDescriptor):
--> 977 value.instance_init(self)
978
979
~/anaconda3/envs/myenv/lib/python3.7/site-packages/traitlets/traitlets.py in instance_init(self, obj)
520 if (self._dynamic_default_callable(obj) is None) \
521 and (self.default_value is not Undefined):
--> 522 v = self._validate(obj, self.default_value)
523 if self.name is not None:
524 obj._trait_values[self.name] = v
~/anaconda3/envs/myenv/lib/python3.7/site-packages/traitlets/traitlets.py in _validate(self, obj, value)
589 return value
590 if hasattr(self, 'validate'):
--> 591 value = self.validate(obj, value)
592 if obj._cross_validation_lock is False:
593 value = self._cross_validate(obj, value)
~/anaconda3/envs/myenv/lib/python3.7/site-packages/traitlets/traitlets.py in validate(self, obj, value)
1975 if not isinstance(value, float):
1976 self.error(obj, value)
-> 1977 return _validate_bounds(self, obj, value)
1978
1979
~/anaconda3/envs/myenv/lib/python3.7/site-packages/traitlets/traitlets.py in _validate_bounds(trait, obj, value)
1850 "specified".format(
1851 name=trait.name, klass=class_of(obj),
-> 1852 value=value, max_bound=trait.max))
1853 return value
1854
TraitError: The value of the 'vmax' trait of a Plots instance should not be greater than 0.182117074882355, but a value of 1.0 was specified
In fact, rerunning the first plot code also then triggers the error, and error can only be cleared by restarting kernel