-
Notifications
You must be signed in to change notification settings - Fork 475
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
Quantity.copy and Quantity.mean not idempotent #678
Comments
The offending line in question is in quantity.py where the magnitude is forced to ndarray. |
Try to change the line to make a copy a operate on that instead of working on the same object and run the tests. By the way, there is a very interesting PR for pandas and Pint #672 |
@hgrecco I am not quite sure what you are suggesting.
The handling of
I looked at a couple of the methods handled through Even if it is necessary to force the magnitude to an |
sorry if I was not clear. I meant to avoid that reassignment. |
@hgrecco - this tripped me up again. It is a really subtle bug. I still am not sure what reassignment you refer to in your most recent response. I don't believe you meant, I should avoid calling |
Revisit after #905 |
I am closing this as it is taken care by #925 |
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 <github@jont.cc>
Hi,
for some reason I need to use pandas dataframes with multiindex, instead of numpy arrays.
These dataframes have the structure
Everything works, except
mean()
andcopy()
alter the Quantity object - which I would not expect at all.The above fails at the penultimate and final assertions with
AttributeError: 'numpy.ndarray' object has no attribute 'index'
. In other words,copy
andmean
alter the Quantity instance. That is a problem for me.The text was updated successfully, but these errors were encountered: