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 #1974

Closed
doutriaux1 opened this issue May 16, 2016 · 5 comments
Closed

numpy.NewAxis broken #1974

doutriaux1 opened this issue May 16, 2016 · 5 comments
Assignees
Milestone

Comments

@doutriaux1
Copy link
Contributor

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)
@doutriaux1
Copy link
Contributor Author

for now a wrork around:

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

@doutriaux1
Copy link
Contributor Author

@lee1043 thanks for reporting this bug

@doutriaux1
Copy link
Contributor Author

maybe 3.0 target?

@doutriaux1 doutriaux1 modified the milestones: 3.0, 2.6 Jun 8, 2016
@dnadeau4
Copy link
Contributor

dnadeau4 commented Aug 25, 2016

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
Copy link
Contributor

This issue was moved to CDAT/cdms#6

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