Skip to content

Add minimum Scipp requirement? #463

@SimonHeybrock

Description

@SimonHeybrock

According to blame this was introduced 2 weeks ago. I think it requires https://github.com/scipp/scipp/releases/tag/25.04.0 now as a minimum? Or am I missing something?

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[5], line 6
      4 # Load only first run
      5 first_run = sans_workflow.compute(loaded[0])
----> 6 sc.DataGroup(sc.collapse(first_run['data'], keep='tof')).plot()

File ~/.conda/envs/mantid_env/lib/python3.10/site-packages/scipp/core/data_group.py:549, in DataGroup.plot(self, *args, **kwargs)
    546 def plot(self, *args: Any, **kwargs: Any) -> Any:
    547     import plopp
--> 549     return plopp.plot(self, *args, **kwargs)

File ~/.conda/envs/mantid_env/lib/python3.10/site-packages/plopp/plotting/plot.py:105, in plot(obj, aspect, cbar, coords, errorbars, figsize, grid, ignore_size, mask_color, norm, scale, title, vmin, vmax, legend, **kwargs)
    103 ndims = set()
    104 for n in nodes:
--> 105     ndims.add(n().ndim)
    106 if len(ndims) > 1:
    107     raise ValueError(
    108         'All items given to the plot function must have the same '
    109         f'number of dimensions. Found dimensions {ndims}.'
    110     )

File ~/.conda/envs/mantid_env/lib/python3.10/site-packages/plopp/core/node_class.py:77, in Node.__call__(self)
     76 def __call__(self) -> Any:
---> 77     return self.request_data()

File ~/.conda/envs/mantid_env/lib/python3.10/site-packages/plopp/core/node_class.py:137, in Node.request_data(self)
    133     args = (parent.request_data() for parent in self.parents)
    134     kwargs = {
    135         key: parent.request_data() for key, parent in self.kwparents.items()
    136     }
--> 137     self._data = self.func(*args, **kwargs)
    138 return self._data

File ~/.conda/envs/mantid_env/lib/python3.10/site-packages/plopp/plotting/common.py:295, in preprocess(obj, name, ignore_size, coords)
    293 out = _add_missing_dimension_coords(out)
    294 out = _drop_non_dimension_coords(out)
--> 295 out = _handle_coords_with_left_over_dimensions(out)
    296 _check_coord_sanity(out)
    297 return out

File ~/.conda/envs/mantid_env/lib/python3.10/site-packages/plopp/plotting/common.py:214, in _handle_coords_with_left_over_dimensions(da)
    202 def _handle_coords_with_left_over_dimensions(da: sc.DataArray) -> sc.DataArray:
    203     """
    204     In some rare cases, the coordinate may have dimensions that are not present in the
    205     data array. This can happen for example when a 2d coord with bin edges is sliced
   (...)
    211     dimension that is not present in the data array.
    212     """
    213     return da.assign_coords(
--> 214         {
    215             name: da.coords[name].mean(
    216                 [dim for dim in da.coords[name].dims if dim not in da.dims]
    217             )
    218             for name in da.coords
    219         }
    220     )

File ~/.conda/envs/mantid_env/lib/python3.10/site-packages/plopp/plotting/common.py:215, in <dictcomp>(.0)
    202 def _handle_coords_with_left_over_dimensions(da: sc.DataArray) -> sc.DataArray:
    203     """
    204     In some rare cases, the coordinate may have dimensions that are not present in the
    205     data array. This can happen for example when a 2d coord with bin edges is sliced
   (...)
    211     dimension that is not present in the data array.
    212     """
    213     return da.assign_coords(
    214         {
--> 215             name: da.coords[name].mean(
    216                 [dim for dim in da.coords[name].dims if dim not in da.dims]
    217             )
    218             for name in da.coords
    219         }
    220     )

File ~/.conda/envs/mantid_env/lib/python3.10/site-packages/scipp/core/reduction.py:67, in mean(x, dim)
     65     return _call_cpp_func(_cpp.mean, x)  # type: ignore[return-value]
     66 else:
---> 67     return _call_cpp_func(_cpp.mean, x, dim=dim)

File ~/.conda/envs/mantid_env/lib/python3.10/site-packages/scipp/core/_cpp_wrapper_util.py:27, in call_func(func, *args, **kwargs)
     25     return data_group_nary(func, *args, **kwargs)
     26 if out is None:
---> 27     return func(*args, **kwargs)
     28 else:
     29     return func(*args, **kwargs, out=out)

TypeError: mean(): incompatible function arguments. The following argument types are supported:
    1. (x: scipp._scipp.core.Variable) -> scipp._scipp.core.Variable
    2. (x: scipp._scipp.core.Variable, dim: str) -> scipp._scipp.core.Variable
    3. (x: scipp._scipp.core.DataArray) -> scipp._scipp.core.DataArray
    4. (x: scipp._scipp.core.DataArray, dim: str) -> scipp._scipp.core.DataArray
    5. (x: scipp._scipp.core.Dataset) -> scipp._scipp.core.Dataset
    6. (x: scipp._scipp.core.Dataset, dim: str) -> scipp._scipp.core.Dataset

Invoked with: <scipp.Variable> (tof: 501)    float64            [µs]  [5, 205, ..., 99805, 100000]; kwargs: dim=[]

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions