8000 BUG: ma: Several functions in the ma module return None when given a scalar. · Issue #3367 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: ma: Several functions in the ma module return None when given a scalar. #3367

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

Closed
WarrenWeckesser opened this issue May 26, 2013 · 0 comments · Fixed by #6537
Closed
Labels
component: numpy.ma masked arrays

Comments

@WarrenWeckesser
Copy link
Member

Here's an example, using ma.atleast_1d:

In [4]: np.__version__
Out[4]: '1.8.0.dev-31a5501'

When given a scalar, the regular version of atleast_1d returns an array:

In [5]: x = np.atleast_1d(1.0)

In [6]: x
Out[6]: array([ 1.])

ma.atleast_1d returns None:

In [7]: x = np.ma.atleast_1d(1.0)

In [8]: print x
None

ma.atleast_1d and several other functions in the ma module are defined using the class _fromnxfunction (defined in numpy/ma/extras.py). In the __call__ method of this class, in the case where len(args) == 1, the code handles the cases where the single argument is an ndarray, a tuple or list. If the single argument is not one of these, the code falls through to the end without returning anything.

The non-masked versions of these accept a scalar, so the masked version should too:

atleast_1d
atleast_2d
atleast_3d
diagflat
jjhelmus added a commit to jjhelmus/numpy that referenced this issue Oct 21, 2015
The np.ma.atleast_1d, np.ma.atleast_2d, np.ma.atleast_3d and np.ma.diagflat
function return arrays when given a scalar in the same manner as their non-ma
counterparts.  Previously these function would return None.

Additionally, the np.ma vstack, row_stack, hstack, column_stack, dstack, and
hsplit functions now raise an expection when given a scalar argument.

closes numpy#3367
charris pushed a commit to charris/numpy that referenced this issue Oct 21, 2015
The np.ma.atleast_1d, np.ma.atleast_2d, np.ma.atleast_3d and np.ma.diagflat
function return arrays when given a scalar in the same manner as their non-ma
counterparts.  Previously these function would return None.

Additionally, the np.ma vstack, row_stack, hstack, column_stack, dstack, and
hsplit functions now raise an expection when given a scalar argument.

closes numpy#3367
@charris charris mentioned this issue Oct 21, 2015
jaimefrio pushed a commit to jaimefrio/numpy that referenced this issue Mar 22, 2016
The np.ma.atleast_1d, np.ma.atleast_2d, np.ma.atleast_3d and np.ma.diagflat
function return arrays when given a scalar in the same manner as their non-ma
counterparts.  Previously these function would return None.

Additionally, the np.ma vstack, row_stack, hstack, column_stack, dstack, and
hsplit functions now raise an expection when given a scalar argument.

closes numpy#3367
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: numpy.ma masked arrays
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
0