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

Set __module__ for exported functions. #985

Merged
merged 3 commits into from Jun 22, 2021
Merged

Conversation

dopplershift
Copy link
Member

Fixes #968. Resets the __module__ on our exported functions so that they appear from the proper namespace when printed in IPython/Jupyter notebook. Also fixes a couple places where we were incorrectly putting the objects themselves, rather than their names, into __all__. (Found because those cases break this new code.)

@dopplershift dopplershift added Area: Infrastructure Pertains to project infrastructure (e.g. CI, linting) Type: Enhancement Enhancement to existing functionality labels Dec 17, 2018
@dopplershift dopplershift added this to the 0.10 milestone Dec 17, 2018
Copy link
Contributor

@jrleeman jrleeman left a comment

Choose a reason for hiding this comment

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

Just some flake things, but otherwise I'm good with this:

____________________ FLAKE8-check(ignoring F405 W503 D999) _____________________
/home/travis/build/Unidata/MetPy/metpy/plots/__init__.py:25:5: F401 '.cartopy_utils.USCOUNTIES' imported but unused
/home/travis/build/Unidata/MetPy/metpy/plots/__init__.py:25:5: F401 '.cartopy_utils.USSTATES' imported but unused
_______________________ FLAKE8-check(ignoring F405 W503) _______________________
/home/travis/build/Unidata/MetPy/metpy/plots/_util.py:20:1: E302 expected 2 blank lines, found 1
_______________________ FLAKE8-check(ignoring F405 W503) _______________________
/home/travis/build/Unidata/MetPy/metpy/tests/test_packaging.py:11:1: E302 expected 2 blank lines, found 1
/home/travis/build/Unidata/MetPy/metpy/tests/test_packaging.py:11:1: D103 Missing docstring in public function

@dopplershift
Copy link
Member Author

😡 I was running flake8 regularly here to try to avoid this. And apparently did not do it on the last iteration.

@dopplershift
Copy link
Member Author

Alright, cleaned up.

Copy link
Contributor

@jrleeman jrleeman left a comment

Choose a reason for hiding this comment

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

3.6 docs are failing with this and similar (I already kicked the build once)

________________ [doctest] metpy.interpolate.log_interpolate_1d ________________
EXAMPLE LOCATION UNKNOWN, not showing all tests of that example
??? >>> x_log = np.array([1e3, 1e4, 1e5, 1e6])
UNEXPECTED EXCEPTION: NameError("name 'np' is not defined",)
Traceback (most recent call last):
  File "/opt/python/3.6.7/lib/python3.6/doctest.py", line 1330, in __run
    compileflags, 1), test.globs)
  File "<doctest metpy.interpolate.log_interpolate_1d[0]>", line 1, in <module>
NameError: name 'np' is not defined

@dopplershift
Copy link
Member Author

dopplershift commented Dec 20, 2018

Weird. Importing numpy within the __init__.py for the sub packages in question fixes it up--doctest must be doing some magic to determine the globals for running the doc examples. This has become a bit trickier than I want right now, so I'm going to punt this from the 0.10 release.

@dopplershift dopplershift modified the milestones: 0.10, 0.11 Dec 20, 2018
@dopplershift dopplershift modified the milestones: 0.11, 0.12 Jun 17, 2019
@dopplershift dopplershift modified the milestones: 0.12, 1.0 Nov 26, 2019
@dopplershift dopplershift modified the milestones: 1.0, 1.1 Jan 10, 2020
Base automatically changed from master to main February 22, 2021 22:39
@dopplershift dopplershift force-pushed the set-module branch 2 times, most recently from fe0a7f9 to 1f508bd Compare June 21, 2021 21:00
This causes the functions to show up under the proper namespace, rather
than the original module, when printed in IPython/notebook.
Not sure why this PR necessitates this, but these additions are fine.
@dcamron dcamron merged commit 77b0d26 into Unidata:main Jun 22, 2021
@dopplershift dopplershift deleted the set-module branch June 22, 2021 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Infrastructure Pertains to project infrastructure (e.g. CI, linting) Type: Enhancement Enhancement to existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Set __module__ on exported functions, etc.
3 participants