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

Allow passing units as strings to NDCube.to #605

Merged
merged 2 commits into from Mar 15, 2023

Conversation

wtbarnes
Copy link
Member

This PR fixes a bug where passing a string representation of a unit to NDCube raises the following TypeError,

File ~/mambaforge/envs/coronal-rain-observables/lib/python3.10/site-packages/ndcube/ndcube.py:964, in NDCube.to(self, new_unit, **kwargs)
    946 def to(self, new_unit, **kwargs):
    947     """Convert instance to another unit.
    948 
    949     Converts the data, uncertainty and unit and returns a new instance
   (...)
    962         A new instance with the new unit and data and uncertainties scales accordingly.
    963     """
--> 964     return self * (self.unit.to(new_unit, **kwargs) * new_unit / self.unit)

TypeError: can't multiply sequence by non-int of type 'float'

@wtbarnes wtbarnes added this to the 2.1.1 milestone Mar 13, 2023
@nabobalis nabobalis modified the milestones: 2.1.1, 2.1.2 Mar 14, 2023
@DanRyanIrish DanRyanIrish merged commit a23aa1b into sunpy:main Mar 15, 2023
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants