Skip to content

MAINT: add test to prevent new public-looking modules being added #14454

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

Merged
merged 10 commits into from
Sep 20, 2019

Conversation

rgommers
Copy link
Member

@rgommers rgommers commented Sep 8, 2019

There is more work to do (added a FIXME), but that's for another time. Preventing to add new submodules is a good start. Also added some documentation, and split things into public and private submodules with comments.

The change to numpy.lib.mixins.__all__ shows that people have been working around our import * mess sometimes. Not adding some public object to an __all__ dict is incorrect of course - need a more structural fix by getting rid of * imports.

@rgommers rgommers added 05 - Testing 30 - API 62 - Python API Changes or additions to the Python API. Mailing list should usually be notified. labels Sep 8, 2019
@rgommers
Copy link
Member Author

rgommers commented Sep 8, 2019

Hmm, we start with a failure that I can't reproduce locally:

>           raise AssertionError("Found unexpected modules: {}".format(modnames))
E           AssertionError: Found unexpected modules: ['numpy.core.generate_numpy_api']

shows up for an install, but not an in-place build. adding it to the list

@rgommers rgommers changed the title WIP: TST: add test to prevent new public-looking modules being added MAINT: add test to prevent new public-looking modules being added Sep 8, 2019
@rgommers rgommers added this to the 1.18.0 release milestone Sep 8, 2019
@eric-wieser
Copy link
Member

The change to numpy.lib.mixins.all shows that people have been working around our import * mess sometimes.

Can you elaborate on what you mean by this?

@rgommers
Copy link
Member Author

rgommers commented Sep 9, 2019

The change to numpy.lib.mixins.all shows that people have been working around our import * mess sometimes.

Can you elaborate on what you mean by this?

The comment explicitly said not to add NDArrayOperatorsMixin because it would then end up in the main numpy namespace. While that goal is good, it's incorrect to have a public function not in the __all__ dict in the file it's in. Also, this effectively has made numpy.lib.mixins public, because the mixin didn't end up in numpy.lib even though there's a from .mixins import * in numpy/lib/__init__.py; I'm not sure what the intent was there.

The root cause is that in our main __init__.py there's a from .lib import *, which makes little sense.

@rgommers rgommers force-pushed the test-public-modules branch 2 times, most recently from fe73481 to 069e115 Compare September 19, 2019 08:10
Also remove `numpy.ma.version.py`, it was not importable and served
no purpose.
@mattip mattip merged commit 3096f1a into numpy:master Sep 20, 2019
@mattip
Copy link
Member

mattip commented Sep 20, 2019

Thanks @rgommers. I guess the next step is to identify candidates for namespace deprecation.

@rgommers rgommers deleted the test-public-modules branch September 20, 2019 07:11
@rgommers
Copy link
Member Author

I guess the next step is to identify candidates for namespace deprecation.

Before that, lower-hanging fruit may be to remove info.py files, add some __all__ dicts, and clean up existing namespaces (e.g. removing numpy.math really shouldn't require a deprecation).

"random.philox",
"random.sfc64",
"testing.decorators",
"testing.noseclasses",
Copy link
Member

Choose a reason for hiding this comment

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

This broke the wheel builds, I suspect because nose is not present in those builds. Nose doesn't support recent Python3 out of the box.

Copy link
Member Author

Choose a reason for hiding this comment

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

do you have a link?

Copy link
Member

Choose a reason for hiding this comment

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

nose is optional, and if not present an import error will be raised if a attempt to import it is made.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

thanks. okay that's easy to fix, PR to follow

rgommers added a commit to rgommers/numpy that referenced this pull request Sep 21, 2019
Removes these files that were deprecated since 1.15.0:

- numpy/testing/decorators.py
- numpy/testing/noseclasses.py
- numpy/testing/nosetester.py

This also resolves a failure in the recently introduced tests
in `test_public_api.py` (see numpygh-14454).  Closes numpygh-14566
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
05 - Testing 30 - API 62 - Python API Changes or additions to the Python API. Mailing list should usually be notified.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants