-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Add insert method to Quantity #3049
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
Conversation
|
@taldcroft - not sure this is the way to go for #3011 (will comment there about that), but in principle I don't mind the idea of an insert method. But for p.s. EDITED to correct above. It does work: |
|
D'oohh! Yes, that is much better, thanks. |
|
This was driven by thinking about getting |
|
@mhvk - implemented your idea and added tests. This is ready for final review (assuming that travis passes). |
astropy/units/quantity.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a big deal, but it may be good to give an example where one sees the unit conversion is done. So perhaps insert 10*u.km?
|
Apart from my small comment, this looks good. Indeed, better than good -- nice to see the test that checks that conversion of float to int leads to an exception! |
|
@mhvk - it turns out there are more issues related to older versions of numpy and integer Quantities. In particular: I think this is reasonable behavior because in general unit conversions can turn things into float. But this made it kind of silly/annoying to write tests that start from integer quantities. |
|
@taldcroft - the build failure seems fake -- I restarted it. |
|
Me too, maybe at the exact same moment... |
Add insert method to Quantity
This is needed for #3011. Before I write tests etc will this idea and implementation be acceptable?