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

Comments

Projects
None yet
2 participants
@doutriaux1
Member

doutriaux1 commented May 16, 2016

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 doutriaux1 added this to the 2.6 milestone May 16, 2016

@doutriaux1

This comment has been minimized.

Member

doutriaux1 commented May 16, 2016

for now a wrork around:

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

This comment has been minimized.

Member

doutriaux1 commented May 16, 2016

@lee1043 thanks for reporting this bug

@doutriaux1

This comment has been minimized.

Member

doutriaux1 commented May 25, 2016

maybe 3.0 target?

@doutriaux1 doutriaux1 modified the milestones: 3.0, 2.6 Jun 8, 2016

@dnadeau4

This comment has been minimized.

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 dnadeau4 added the cdms2 label Sep 13, 2016

@dnadeau4

This comment has been minimized.

Contributor

dnadeau4 commented Sep 13, 2016

This issue was moved to CDAT/cdms#6

@dnadeau4 dnadeau4 closed this Sep 13, 2016

@dnadeau4 dnadeau4 reopened this Sep 17, 2016

dnadeau4 added a commit that referenced this issue Sep 17, 2016

@dnadeau4 dnadeau4 closed this Sep 19, 2016

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