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

Convert quantities to scalars before formatting #330

Merged
merged 3 commits into from Mar 1, 2017

Conversation

jrleeman
Copy link
Contributor

The pint implementation of format will not take a non empty format string, so this would fail when units were included (#307). Currently solution is to check if there is a units attribute and turn it into a scalar.

@jrleeman
Copy link
Contributor Author

After our conversation I realized we never decided exactly how we were going to work around this strange issue. We'll still have to check for units regardless.

@dopplershift
Copy link
Member

I thought it was:

  1. Use np.asscalar in the list comprehension
  2. Make the default formatter check for units and use magnitude; I'd like to verify that this second step is actually necessary to keep units from being displayed.

@jrleeman
Copy link
Contributor Author

jrleeman commented Mar 1, 2017

Looks like as long as we call asscalar we drop the units. The issue with having it in the list comprehension is it fails when v is an integer or anything other than an array.

@dopplershift
Copy link
Member

CLA is stuck for some reason--no need to worry about it.

@dopplershift dopplershift merged commit 6e742cb into Unidata:master Mar 1, 2017
@jrleeman jrleeman deleted the StatonPlot_Units branch March 6, 2017 22:47
@dopplershift dopplershift modified the milestone: Spring 2017 Mar 10, 2017
dopplershift added a commit to dopplershift/MetPy that referenced this pull request Jan 10, 2020
So with pint's advances, it turns out `item()` no longer strips units.
This is Unidata#330 come back for revenge. The right answer is to just drop
units when calling `plot_parameter`. We don't want them, and there's no
format code that will drop units; while one could be added, this
wouldn't work with floats in general.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants