Skip to content

Grouping by string-type coordinate with its name. #3425

@YooSunYoung

Description

@YooSunYoung

Currently sc.group fails if we select a coordinate name to group.

import scipp as sc
from scipp.data import table_xyz

da = table_xyz(100)
da.coords["str_coord"] = sc.array(dims=["row"], values=['a', 'b', 'c', 'd']*25)
da.group('str_coord') # AttributeError: 'scipp._scipp.core.ElementArrayView_string' object has no attribute 'size'

But it works when the group-coordinate is given,

import scipp as sc
from scipp.data import table_xyz

da = table_xyz(100)
da.coords["str_coord"] = sc.array(dims=["row"], values=['a', 'b', 'c', 'd']*25)
da.group(sc.array(dims=['str_coord'], values=['a', 'b', 'c', 'd']))  # works

We should also support selecting the coordinate name of string type coordinate for grouping.

Related to #290

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions