Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gridded dataset notebook raise ValueError #624

Closed
hoxbro opened this issue Apr 16, 2023 · 2 comments · Fixed by #626
Closed

Gridded dataset notebook raise ValueError #624

hoxbro opened this issue Apr 16, 2023 · 2 comments · Fixed by #626
Assignees

Comments

@hoxbro
Copy link
Member

hoxbro commented Apr 16, 2023

Running the examples/user_guide/Gridded_Datasets_I.ipynb and examples/user_guide/Gridded_Datasets_II.ipynb with the latest param and Holoviews, we get the following error: ValueError: kdims: list length must be between 2 and 2 (inclusive).

Related PRs: holoviz/holoviews#5667 and holoviz/param#605

image

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[4], line 4
      1 kdims = ['time', 'longitude', 'latitude']
      2 vdims = ['surface_temperature']
----> 4 xr_dataset = gv.Dataset(xr_ensemble, kdims=kdims, vdims=vdims)
      5 iris_dataset = gv.Dataset(iris_ensemble, kdims=kdims, vdims=vdims)

File ~/Repos/holoviz/geoviews/geoviews/element/geo.py:110, in _Element.__init__(self, data, kdims, vdims, **kwargs)
    108 elif isinstance(data, _Element):
    109     kwargs['crs'] = data.crs
--> 110 super(_Element, self).__init__(data, kdims=kdims, vdims=vdims, **kwargs)

File ~/Repos/holoviz/holoviews/holoviews/core/data/__init__.py:334, in Dataset.__init__(self, data, kdims, vdims, **kwargs)
    331 initialized = Interface.initialize(type(self), data, kdims, vdims,
    332                                    datatype=kwargs.get('datatype'))
    333 (data, self.interface, dims, extra_kws) = initialized
--> 334 super().__init__(data, **dict(kwargs, **dict(dims, **extra_kws)))
    335 self.interface.validate(self, validate_vdims)
    337 # Handle _pipeline property

File ~/Repos/holoviz/holoviews/holoviews/core/dimension.py:844, in Dimensioned.__init__(self, data, kdims, vdims, **params)
    841 if 'cdims' in params:
    842     params['cdims'] = {d if isinstance(d, Dimension) else Dimension(d): val
    843                        for d, val in params['cdims'].items()}
--> 844 super().__init__(data, **params)
    845 self.ndims = len(self.kdims)
    846 cdims = [(d.name, val) for d, val in self.cdims.items()]

File ~/Repos/holoviz/holoviews/holoviews/core/dimension.py:503, in LabelledData.__init__(self, data, id, plot_id, **params)
    500     util.group_sanitizer.add_aliases(**{alias:long_name})
    501     params['group'] = long_name
--> 503 super().__init__(**params)
    504 if not util.group_sanitizer.allowable(self.group):
    505     raise ValueError("Supplied group %r contains invalid characters." %
    506                      self.group)

File ~/Repos/holoviz/param/param/parameterized.py:3231, in Parameterized.__init__(self, **params)
   3228 self._dynamic_watchers = defaultdict(list)
   3230 self.param._generate_name()
-> 3231 self.param._setup_params(**params)
   3232 object_count += 1
   3234 self.param._update_deps(init=True)

File ~/Repos/holoviz/param/param/parameterized.py:1453, in as_uninitialized.<locals>.override_initialization(self_, *args, **kw)
   1451 original_initialized = parameterized_instance.initialized
   1452 parameterized_instance.initialized = False
-> 1453 fn(parameterized_instance, *args, **kw)
   1454 parameterized_instance.initialized = original_initialized

File ~/Repos/holoviz/param/param/parameterized.py:1704, in Parameters._setup_params(self_, **params)
   1702     self.param.warning("Setting non-parameter attribute %s=%s using a mechanism intended only for parameters", name, val)
   1703 # i.e. if not desc it's setting an attribute in __dict__, not a Parameter
-> 1704 setattr(self, name, val)

File ~/Repos/holoviz/param/param/parameterized.py:382, in instance_descriptor.<locals>._f(self, obj, val)
    380     instance_param.__set__(obj, val)
    381     return
--> 382 return f(self, obj, val)

File ~/Repos/holoviz/param/param/parameterized.py:1266, in Parameter.__set__(self, obj, val)
   1263 if hasattr(self, 'set_hook'):
   1264     val = self.set_hook(obj,val)
-> 1266 self._validate(val)
   1268 _old = NotImplemented
   1269 # obj can be None if __set__ is called for a Parameterized class

File ~/Repos/holoviz/param/param/__init__.py:1671, in List._validate(self, val)
   1666 """
   1667 Checks that the value is numeric and that it is within the hard
   1668 bounds; if not, an exception is raised.
   1669 """
   1670 self._validate_value(val, self.allow_None)
-> 1671 self._validate_bounds(val, self.bounds)
   1672 self._validate_item_type(val, self.item_type)

File ~/Repos/holoviz/param/param/__init__.py:1682, in List._validate_bounds(self, val, bounds)
   1680 if min_length is not None and max_length is not None:
   1681     if not (min_length <= l <= max_length):
-> 1682         raise ValueError("%s: list length must be between %s and %s (inclusive)"%(self.name,min_length,max_length))
   1683 elif min_length is not None:
   1684     if not min_length <= l:

ValueError: kdims: list length must be between 2 and 2 (inclusive)
@hoxbro hoxbro added this to the Version 1.10 milestone Apr 16, 2023
@maximlt
Copy link
Member

maximlt commented Apr 16, 2023

You mean with Param and HoloViews from their main branch?

@hoxbro
Copy link
Member Author

hoxbro commented Apr 16, 2023

Correct, it is not breaking people but needed for the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants