Skip to content

Inconsistent behavior for whitespace in labels #885

Open
@gdementen

Description

@gdementen

We strip (whitespace from) labels in some cases but not in others

In a axis creation string, they are stripped (seems fine to me)

>>> arr = ndtest('a=a0,a1 ,a2')
>>> arr.axes
AxisCollection([
    Axis(['a0', 'a1', 'a2'], 'a')
])

In explicit axis creation, they are not stripped (still fine to me)

>>> arr = ndtest(Axis(['a0', 'a1 '], 'a'))
>>> arr.axes
AxisCollection([
    Axis(['a0', 'a1 '], 'a')
])

When targeting an explicit key on an explicit axis, they are stripped. This is probably a bad idea.

>>> arr[arr.a['a1 ']]
ValueError: a['a1'] is not a valid label for any axis
>>> arr.a['a1 ']
a['a1']
>>> arr[arr.a.i[1]]
1
>>> arr.a[['a1 ', 'a2']]
a['a1 ', 'a2']

We should either strip them during axis creation (with a warning) OR not strip them when targeting a single label on an axis.

We could implement the following:

>>> arr.a['a1 ']
a['a1 ']
>>> arr.a['a1 ,a2']
a['a1', 'a2']
>>> arr.a[['a1 ', 'a2']]
a['a1 ', 'a2']

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions