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

Mutated type in Quantity #509

Closed
cmft opened this issue May 16, 2017 · 3 comments
Closed

Mutated type in Quantity #509

cmft opened this issue May 16, 2017 · 3 comments
Assignees
Labels

Comments

@cmft
Copy link
Contributor

cmft commented May 16, 2017

If I do a np.shape over a Quantity, the operation mutates the type of the .magnitude

See the example below :

#pint.__version__  ('0.8')
#numpy.__version__ ('1.10.1')

import pint
import numpy as np

ureg = pint.UnitRegistry()
q = ureg.Quantity(1)
print type(q.magnitude) # <type 'int'>
np.shape(q) #Out[6]: ()
print type(q.magnitude) # <type 'numpy.ndarray'>
@cmft
Copy link
Contributor Author

cmft commented May 24, 2017

Hi.
I also saw the same problem with np.size method.

@hgrecco
Copy link
Owner

hgrecco commented Dec 3, 2019

Revisit after #905

@hgrecco
Copy link
Owner

hgrecco commented Dec 24, 2019

I am closing this as it is taken care by #925

@hgrecco hgrecco closed this as completed Dec 24, 2019
bors bot added a commit that referenced this issue Dec 27, 2019
957: Add parameterized test for type immutability r=hgrecco a=jthielen

As discussed in #925, this adds a parameterized test to verify that the internal type is not mutated under common operations (as encountered in #399, #481, #509, #622, #678).

- [x] Closes #925, Closes #481
- [x] Executed ``black -t py36 . && isort -rc . && flake8`` with no errors
- [x] The change is fully covered by automated unit tests
- ~~Documented in docs/ as appropriate~~
- [x] Added an entry to the CHANGES file


Co-authored-by: Jon Thielen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants