Skip to content

Re-binning with float32 coords fails with unsupported dtype #3176

@nvaytet

Description

@nvaytet

Binning data first into a single bin, and subsequently re-binning with finer binning works fine with float64

import scipp as sc

table64 = sc.data.table_xyz(1000)
binned64 = table64.bin(x=1)
binned64.bin(x=10)

Screenshot at 2023-06-20 10-53-19

but doing the same with float32 fails

table32 = sc.data.table_xyz(1000).to(dtype='float32')
for k, v in table32.coords.items():
    table32.coords[k] = v.to(dtype='float32')
table32

Screenshot at 2023-06-20 10-52-44

binned32 = table32.bin(x=1)
binned32.bin(x=10)
---------------------------------------------------------------------------
DTypeError                                Traceback (most recent call last)
Cell In [8], line 1
----> 1 binned.bin(x=10)

File ~/code/scipp/install/scipp/core/data_group.py:610, in data_group_overload.<locals>.impl(data, *args, **kwargs)
    608 if isinstance(data, DataGroup):
    609     return data.apply(impl, *args, **kwargs)
--> 610 return func(data, *args, **kwargs)

File ~/code/scipp/install/scipp/core/binning.py:582, in bin(x, arg_dict, **kwargs)
    580 edges = _make_edges(x, arg_dict, kwargs)
    581 erase = _find_replaced_dims(x, edges)
--> 582 return make_binned(x, edges=list(edges.values()), erase=erase)

File ~/code/scipp/install/scipp/core/binning.py:151, in make_binned(x, edges, groups, erase)
    149 if _can_operate_on_bins(x, edges, groups, erase):
    150     return combine_bins(x, edges=edges, groups=groups, dim=erase)
--> 151 return _cpp.bin(x, edges, groups, erase)

DTypeError: 'scipp.bin.begin_edge' does not support dtypes 'int64', 'int64', 'float32', 'span_const_float32', 

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions