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

Units: convert '%' to 'percent' for within the xarray MetPy accessor #1057

Merged
merged 1 commit into from
Jun 12, 2019

Conversation

zbruick
Copy link
Contributor

@zbruick zbruick commented Jun 10, 2019

Because pint does not support '%' as a unit, this update converts DataArray units that are provided as such to 'percent'.

Fixes #1038.

@zbruick zbruick force-pushed the pint_percent branch 2 times, most recently from 95207bd to 67156e9 Compare June 10, 2019 19:55
Copy link
Collaborator

@kgoebber kgoebber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice easy change. Just a few lint issues that came up, the suggestions "should" work. Be sure to flake8 the test_xarray.py file to be sure.

@@ -84,6 +84,13 @@ def test_units(test_var):
assert test_var.metpy.units == units('kelvin')


def test_units_percent():
"""Test that '%' is converted to 'percent' """
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few lint issues, need a period of the docstring.

Suggested change
"""Test that '%' is converted to 'percent' """
"""Test that '%' is converted to 'percent'."""

def test_units_percent():
"""Test that '%' is converted to 'percent' """
test_var_percent = xr.open_dataset(get_test_data('irma_gfs_example.nc',
as_file_obj=False))['Relative_humidity_isobaric']
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is too long...

Suggested change
as_file_obj=False))['Relative_humidity_isobaric']
test_var_percent = xr.open_dataset(
get_test_data('irma_gfs_example.nc',
as_file_obj=False))['Relative_humidity_isobaric']

this update converts '%' units to 'percent' units within the
MetPy xarray accessor.

Fixes Unidata#1038.
@zbruick
Copy link
Contributor Author

zbruick commented Jun 11, 2019

Took care of those lint issues. Should be good to go.

@kgoebber kgoebber self-assigned this Jun 11, 2019
@dopplershift dopplershift added Area: Xarray Pertains to xarray integration Type: Enhancement Enhancement to existing functionality labels Jun 11, 2019
@dopplershift dopplershift added this to the 0.11 milestone Jun 11, 2019
@dopplershift
Copy link
Member

Travis failure is just matplotlib. Merging over it.

@dopplershift dopplershift merged commit c6ef3e1 into Unidata:master Jun 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Xarray Pertains to xarray integration Type: Enhancement Enhancement to existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle ‘%’ unit
3 participants