Thanks to visit codestin.com
Credit goes to github.com

Skip to content

MAINT: Move pytesttester outside of np.testing, to avoid creating unnecessary import dependencies #11473

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 1 commit into from
Jul 2, 2018

Conversation

eric-wieser
Copy link
Member

@eric-wieser eric-wieser commented Jul 1, 2018

pytesttester is used by every single subpackage, so making it depend on np.testing just creates cyclic dependencies that can lead to circular imports

Importantly, this breaks a cyclic dependency between np.lib and np.core

Relates to #11457

@eric-wieser
Copy link
Member Author

eric-wieser commented Jul 1, 2018

The motivation here was to try and make add_newdocs not be our main entry point, but attempting to change that caused import cycles through np.testing. This should resolve those cycles

Copy link
Contributor

@mhvk mhvk 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. Only request is a slight expansion on the comment you added.

Maybe also cc @charris and @rgommers

p.s. Obviously, with this reducing the import time becomes trivial, but fine to leave that separate - the circular imports is reason enough.

@@ -23,6 +23,8 @@
In practice, tests run from the numpy repo are run in develop mode. That
includes the standard ``python runtests.py`` invocation.

This module is imported by every numpy subpackage, so lies at the top level to
simplify circular import issues.
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add something like "This is also why numpy and pytest are not imported on top, but rather inside _show_numpy_info and PytestTester.__call__"

from ._private.nosetester import (
run_module_suite, NoseTester as Tester
)
from ._private.utils import *
Copy link
Contributor

Choose a reason for hiding this comment

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

Not that I mind, but was there a specific reason for the reordering?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this was accidental

…ecessary import dependencies

pytesttester is used by every single subpackage, so making it depend on np.testing just creates cyclic dependencies that can lead to circular imports

Relates to numpy#11457
@eric-wieser
Copy link
Member Author

Comments updated

@rgommers
Copy link
Member

rgommers commented Jul 2, 2018

LGTM, thanks @eric-wieser

@charris
Copy link
Member

charris commented Jul 2, 2018

I note that the imports of sys and os could be moved into __call__, don't know that that would make much difference.

@eric-wieser
Copy link
Member Author

@charris: I'd be very surprised if numpy doesn't already import those somewhere else anyway. At any rate, there's no risk of a circular dependency there

Copy link
Contributor

@mhvk mhvk left a comment

Choose a reason for hiding this comment

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

Thanks, the added comment is now very clear.

@mhvk
Copy link
Contributor

mhvk commented Jul 2, 2018

Merging, since tests passed before and only a comment was changed.

@mhvk mhvk merged commit a854e70 into numpy:master Jul 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants