Skip to content

np.vstack does no longer accept generator expressions in numpy master #12274

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
ogrisel opened this issue Oct 26, 2018 · 3 comments
Closed

np.vstack does no longer accept generator expressions in numpy master #12274

ogrisel opened this issue Oct 26, 2018 · 3 comments

Comments

@ogrisel
Copy link
Contributor

ogrisel commented Oct 26, 2018

It seems that the scikit-learn test job that runs against numpy master found a breaking change in numpy:

scikit-learn/scikit-learn#12467

Minimal reproduction case:

>>> import numpy as np
>>> np.__version__
'1.16.0.dev0+8aa1214'
>>> np.vstack([0] for _ in range(3))
Traceback (most recent call last):
  File "<ipython-input-5-842ad8069d40>", line 1, in <module>
    np.vstack([0] for _ in range(3))
  File "/opt/venvs/py37/lib/python3.7/site-packages/numpy/core/overrides.py", line 151, in public_api
    implementation, public_api, relevant_args, args, kwargs)
  File "/opt/venvs/py37/lib/python3.7/site-packages/numpy/core/overrides.py", line 96, in array_function_implementation_or_override
    return implementation(*args, **kwargs)
  File "/opt/venvs/py37/lib/python3.7/site-packages/numpy/core/shape_base.py", line 260, in vstack
    return _nx.concatenate([atleast_2d(_m) for _m in tup], 0)
  File "/opt/venvs/py37/lib/python3.7/site-packages/numpy/core/overrides.py", line 151, in public_api
    implementation, public_api, relevant_args, args, kwargs)
  File "/opt/venvs/py37/lib/python3.7/site-packages/numpy/core/overrides.py", line 96, in array_function_implementation_or_override
    return implementation(*args, **kwargs)
  File "/opt/venvs/py37/lib/python3.7/site-packages/numpy/core/multiarray.py", line 193, in concatenate
    return _multiarray_umath.concatenate(arrays, axis, out)
ValueError: need at least one array to concatenate

This used to work in past versions of numpy:

>>> import numpy as np
>>> np.__version__
'1.14.5'
>>> np.vstack([0] for _ in range(3))
array([[0],
       [0],
       [0]])
@ogrisel ogrisel changed the title np.vstack does not longer accept generator expressions in numpy master np.vstack does no longer accept generator expressions in numpy master Oct 26, 2018
@tylerjereddy
Copy link
Contributor

For SciPy we just switched from generator to list comprehension to resolve this -- i.e., scipy/scipy#9405

It is related to the array function NEP changes -- see #12263 (comment) . Stephan may re-enable the behavior for a while, but maybe best not to depend on it long term.

@amueller
Copy link

close this as duplicate of #12263?

@tylerjereddy
Copy link
Contributor

Yes, let's focus on the issue there

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

No branches or pull requests

3 participants