Skip to content

make axis['multiple;groups'] work #151

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

Open
gdementen opened this issue Mar 14, 2017 · 1 comment
Open

make axis['multiple;groups'] work #151

gdementen opened this issue Mar 14, 2017 · 1 comment

Comments

@gdementen
Copy link
Contributor

I am not sure we should keep axis['a_string'] being interpreted, but if we do the title should work.

Salvaged from my comments in #145.

However (and this is a bit silly that I did not make it work -- but to my defense, I did not expect you to merge that PR), what you used as an example is broken at this point, because the result is not a valid index in an array:

>>> year = Axis('year', '2001..2010')
>>> year['2001:2004;2008;2009']
year[slice(2001, 2004, None), [2008, 2009]]
>>> arr = ndrange(year)
>>> arr.sum(year['2001:2004;2008,2009'])
TypeError                                 Traceback (most recent call last)
...
TypeError: unhashable type: 'slice'
>>> # this works though
... arr.sum(tuple(year['2001:2004;2008,2009']))
year | 2001:2004 | 2008,2009
     |         6 |        15
@gdementen
Copy link
Contributor Author

I think

year['2001:2004;2008;2009']

should be equivalent to

(year[2001:2004], year[2008], year[2009])

while

year['2001:2004,2008,2009']

should be equivalent to

year[2001,2002,2003,2004,2008,2009]

@alixdamman alixdamman added this to the 0.32 milestone Jul 20, 2018
@alixdamman alixdamman removed this from the 0.32 milestone Aug 1, 2019
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

2 participants