-
Notifications
You must be signed in to change notification settings - Fork 474
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 arange unsupported #484
Comments
The correct way would be: y = np.arange(0, 1 * ureg.meter, 0.1 * ureg.meter)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: setting an array element with a sequence. However, this fails (with a different error). The reason is that |
Something like |
The problem is that there is no way to tell numpy that we will handle it. The suggested way is [1, 0.1] * ureg.meter |
And `np.arange(0, 1, 0.1)*ureg.meter`
On Jun 14, 2017 7:04 PM, "Hernan Grecco" <[email protected]> wrote:
The problem is that there is no way to tell numpy that we will handle it.
The suggested way is
[1, 0.1] * ureg.meter
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#484 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AH946-PbhytjgXlaClI7CaDvSos2aS8Vks5sEJEjgaJpZM4MRkYP>
.
|
I had the same problem and I had an idea: The problem is that if the Quantity objects are ndarrays or similar (which numpy determines by calling Therefore, by not responding to
This code is not working for numpy functions taking more than 1 argument but I thought I would share it. |
Just came across this issue while trying to convert a list of Quantities to a numpy array: >>> from myproject import Q_
>>> a = Q_(1,'nm')
>>> import numpy as np
>>> np.array([a, a])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: setting an array element with a sequence. |
Revisit after #905 |
Currently, However, in numpy/numpy#12379, there are comments to the effect that, in principal, np.arange(0, 1, 0.1) * ureg.meter |
Versions:
python
: v3.6.0numpy
: v1.12.0pint
: 0.8.dev0 (commit de8fdff)Results in:
Since one can do
np.linspace(0, x, 10)
without problems I think this is a bug, although I may be misunderstanding and this may be an implication of the stated numpy supportThe text was updated successfully, but these errors were encountered: