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

Doc/warning improvements #2415

Merged
merged 6 commits into from
Apr 6, 2022
Merged

Conversation

dopplershift
Copy link
Member

Description Of Changes

With the last one:

import metpy.calc as mpcalc
import numpy as np

mpcalc.wind_speed(np.ma.array([1]), np.ma.array([2]))

gives:

ValueError: `wind_speed` given arguments with incorrect units: `u` requires "[speed]" but given "none", `v` requires "[speed]" but given "none"
A masked array `m` can be assigned a unit as follows:
    from metpy.units import units
    m = units.Quantity(m, "m/s")
For more information see the Units Tutorial: https://unidata.github.io/MetPy/latest/tutorials/unit_tutorial.html

whereas with a numpy array it gives:

ValueError: `wind_speed` given arguments with incorrect units: `u` requires "[speed]" but given "none", `v` requires "[speed]" but given "none"
A xarray DataArray or numpy array `x` can be assigned a unit as follows:
    from metpy.units import units
    x = x * units("m/s")
For more information see the Units Tutorial: https://unidata.github.io/MetPy/latest/tutorials/unit_tutorial.html

Checklist

This replaces telling it to document imported names.
This fixes the oddity where only metpy.io was listed in full, while the
others showed the trailing module name. Instead, provide a descriptive
name along with teh full module name.
This is one of a few steps it would take to get module-level attributes
(e.g. instances) listed in the generated docs. Unfortunately, while
sphinx can parse files and grab assignments that have doc-comments with
them ('#:'), we have problems because we're pulling instances out of
sub-modules.
This make the message appropriate to whether we were given a MaskedArray
or not.
@dopplershift dopplershift requested review from a team and jthielen as code owners April 6, 2022 02:27
@dopplershift dopplershift requested review from dcamron and removed request for a team April 6, 2022 02:27
@dopplershift dopplershift added Type: Bug Something is not working like it should Area: Docs Affects documentation Type: Enhancement Enhancement to existing functionality Area: Units Pertains to unit information labels Apr 6, 2022
@dopplershift dopplershift added this to the 1.3.0 milestone Apr 6, 2022
@dopplershift
Copy link
Member Author

dopplershift commented Apr 6, 2022

Current 1.2 docs (note the weird metpy.io in the sidebar):
image

With this PR:
image

Copy link
Member

@dcamron dcamron left a comment

Choose a reason for hiding this comment

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

I like these changes, and final product seems to come together consistently on my machine and on actions.

Copy link
Collaborator

@jthielen jthielen left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@dopplershift dopplershift merged commit 00951a8 into Unidata:main Apr 6, 2022
@dopplershift dopplershift deleted the improve-docs branch April 6, 2022 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Docs Affects documentation Area: Units Pertains to unit information Type: Bug Something is not working like it should Type: Enhancement Enhancement to existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect instruction for assigning units in check_unit error message lcl works on n-dimensional arrays
3 participants