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

Axis.difference(scalar_group) and Axis.difference([scalar_index_group]) fail silently #1104

Open
gdementen opened this issue Apr 25, 2024 · 1 comment

Comments

@gdementen
Copy link
Contributor

>>> a = la.Axis('a=a0..a2')

The following work fine:

>>> a.difference('a0')
Axis(['a1', 'a2'], 'a')
>>> a.difference(a.i[[0]])
Axis(['a1', 'a2'], 'a')
>>> a.difference(a[['a0']])
Axis(['a1', 'a2'], 'a')
>>> a.difference([a['a0']])
Axis(['a1', 'a2'], 'a')

But all the following do not:

>>> a.difference(a['a0'])
Axis(['a0', 'a1', 'a2'], 'a')
>>> a.difference(a.i[0])
Axis(['a0', 'a1', 'a2'], 'a')
>>> a.difference([a.i[0]])
Axis(['a0', 'a1', 'a2'], 'a')

priority high even though this is seldom used because it is a silent failure. There is most likely the same problem in Axis.intersection and Axis.union.

I am unsure all those cases should be supported but the asymmetry between string and groups, or even LGroup and IGroup is puzzling, and the unsupported cases (if any) must fail loudly instead of silently.

@gdementen
Copy link
Contributor Author

FWIW, when doing the operation on a Group, most cases work ?!?

>>> a[:].difference(a.i[0])
a['a1', 'a2'].set()
>>> a[:].difference(a.i[[0]])
a['a1', 'a2'].set()
>>> a[:].difference(a['a0'])
a['a1', 'a2'].set()
>>> a[:].difference('a0')
a['a1', 'a2'].set()
>>> a[:].difference([a['a0']])
a['a1', 'a2'].set()

Except:

>>> a[:].difference([a.i[0]])
a['a0', 'a1', 'a2'].set()

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

No branches or pull requests

1 participant