Turn off warn_infinite for phase_crossover_frequencies() calculation by murrayrm · Pull Request #1106 · python-control/python-control

Choose a reason for hiding this comment

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

Should we use relative imports in test files?

Arguments against relative imports in test files

  • Although the tests/ directory is a subpackage and therefore can use the relative import syntax, this change will prevent running tests from outside of the control package.
  • Users of control necessarily write absolute imports (import control or from control...). Tests of the public API should follow the patterns of users.

Arguments in favor

  • Relative import syntax is more concise.
  • I might have missed something, but none of the CI jobs run the tests against a copy of control other than where they are located. In other words, "running tests from outside of the control package" is not done in practice, so not important to support.
  • We are already using the relative import syntax in config_test.py.

For comparison, neither numpy nor scipy seem to be consistent: most of their tests are written using absolute imports (import numpy or import scipy etc.), but some tests use relative imports.

Conclusion

I like the generality in principle of keeping these as absolute imports, but practically both patterns seem good.