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

CDMS2/MV2.newaxis doesn't work #1722

Closed
durack1 opened this issue Dec 3, 2015 · 2 comments
Closed

CDMS2/MV2.newaxis doesn't work #1722

durack1 opened this issue Dec 3, 2015 · 2 comments
Milestone

Comments

@durack1
Copy link
Member

@durack1 durack1 commented Dec 3, 2015

The numpy.newaxis function should add a new (singleton) axis to an existing variable as per the docs:

>>> type(intTo)
<class 'cdms2.tvariable.TransientVariable'>
>>> intTo_NP = np.array(intTo)
>>> type(intTo_NP)
<type 'numpy.ndarray'>
>>> intTo_NP.shape
(384, 320)
>>> intTo_NP_expanded = intTo_NP[np.newaxis]
>>> intTo_NP_expanded.shape
(1, 384, 320)

But it doesn't seem to work for cdms2/MV2:

>>> intTo.shape
(384, 320)
>>> intTo_expanded = intTo[mv.newaxis]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/uvcdat/2.4.0rc1/lib/python2.7/site-packages/cdms2/avariable.py", line 1401, in __getitem__
    speclist = self._process_specs(key, {})
  File "/usr/local/uvcdat/2.4.0rc1/lib/python2.7/site-packages/cdms2/avariable.py", line 1169, in _process_specs
    raise CDMSError, 'Sorry, you cannot use NewAxis in this context ' + str(specs)
cdms2.error.CDMSError: Sorry, you cannot use NewAxis in this context (None, slice(None, None, None))

It's likely that the plans @dnadeau4 has for cdms2 updates (better wrapping all the existing numpy functions) will solve this, but thought it useful to document.

@durack1 durack1 added this to the 3.0 milestone Dec 3, 2015
@dnadeau4
Copy link
Contributor

@dnadeau4 dnadeau4 commented Oct 5, 2016

fixed with branch numpy1_11

@dnadeau4 dnadeau4 closed this Oct 5, 2016
@durack1
Copy link
Member Author

@durack1 durack1 commented Oct 5, 2016

@dnadeau4 thanks!!

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

Successfully merging a pull request may close this issue.

None yet
2 participants