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

numpy.NewAxis broken #6

Closed
dnadeau4 opened this issue Sep 13, 2016 · 6 comments
Closed

numpy.NewAxis broken #6

dnadeau4 opened this issue Sep 13, 2016 · 6 comments
Assignees
Milestone

Comments

@dnadeau4
Copy link
Contributor

From @doutriaux1 on May 16, 2016 21:45

the follwoing used to work

f=cdms2.open("/usr/local/uvcdat/2.4.1/share/uvcdat/sample_data/clt.nc")
>>> s=f("clt",slice(0,1))
>>> s.shape
(1, 46, 72)
>>> s=f("clt",slice(0,1),squeeze=1)
>>> s.shape
(46, 72)
>>> import cdutil
>>> zm = cdutil.averager(s,axis="x")
>>> zm.shape
(46,)
>>> s2 = s -zm
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/anaconda2/envs/uvcdat-2.4.1/lib/python2.7/site-packages/cdms2/avariable.py", line 1436, in __sub__
    return MV.subtract(self, other)
  File "/usr/local/anaconda2/envs/uvcdat-2.4.1/lib/python2.7/site-packages/cdms2/MV2.py", line 228, in __call__
    maresult = self.mafunc(ta,tb)
  File "/usr/local/anaconda2/envs/uvcdat-2.4.1/lib/python2.7/site-packages/numpy/ma/core.py", line 935, in __call__
    m = umath.logical_or(getmaskarray(a), mb)
ValueError: operands could not be broadcast together with shapes (46,72) (46,) 
>>> s2 = s -zm[:,numpy.newaxis]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/anaconda2/envs/uvcdat-2.4.1/lib/python2.7/site-packages/cdms2/avariable.py", line 1401, in __getitem__
    speclist = self._process_specs(key, {})
  File "/usr/local/anaconda2/envs/uvcdat-2.4.1/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 (slice(None, None, None), None)
>>> s2 = s - zm[:,numpy.newaxis]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/anaconda2/envs/uvcdat-2.4.1/lib/python2.7/site-packages/cdms2/avariable.py", line 1401, in __getitem__
    speclist = self._process_specs(key, {})
  File "/usr/local/anaconda2/envs/uvcdat-2.4.1/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 (slice(None, None, None), None)

Copied from original issue: CDAT/cdat#1974

@dnadeau4
Copy link
Contributor Author

From @doutriaux1 on May 16, 2016 21:46

for now a wrork around:

>>> s,zm  = genutil.grower(s,zm)
>>> s.shape
(46, 72)
>>> zm.shape
(46, 72)

@dnadeau4
Copy link
Contributor Author

From @doutriaux1 on May 16, 2016 21:46

@lee1043 thanks for reporting this bug

@dnadeau4
Copy link
Contributor Author

From @doutriaux1 on May 25, 2016 18:18

maybe 3.0 target?

@dnadeau4
Copy link
Contributor Author

import MV2
import numpy
b=MV2.ones((10,12))
a=b[0]
c=b+a[numpy.newaxis,:]


Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/software/anaconda2/envs/numpy1_11/lib/python2.7/site-packages/cdms2/avariable.py", line 1413, in __getitem__
    speclist = self._process_specs(key, {})
  File "/software/anaconda2/envs/numpy1_11/lib/python2.7/site-packages/cdms2/avariable.py", line 1181, 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))


c=b.asma()+a.asma()[numpy.newaxis,:]

@dnadeau4 dnadeau4 added this to the 3.0 milestone Sep 13, 2016
@dnadeau4
Copy link
Contributor Author

Done!

@durack1
Copy link
Member

durack1 commented Apr 21, 2017

@dnadeau4 related to axes see CDAT/cdat#1738 #41

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