enthought / scimath

Other
67 stars 16 forks source link

Move scimath.interpolate profiling script into its own module #153

Closed mdickinson closed 2 years ago

mdickinson commented 2 years ago

There's a profiling script at the end of scimath.interpolate.interpolate, but running this script via python -m scimath.interpolate.interpolate produces the following slightly worrying warning about "unpredictable behaviour".

(scimath) mdickinson@mirzakhani scimath % python -m scimath.interpolate.interpolate
/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py:127: RuntimeWarning: 'scimath.interpolate.interpolate' found in sys.modules after import of package 'scimath.interpolate', but prior to execution of 'scimath.interpolate.interpolate'; this may result in unpredictable behaviour
  warn(RuntimeWarning(msg))

After adding some print statements for debugging purposes, it's possible to verify thatpython -m scimath.interpolate.interpolate does indeed execute the code in scimath/interpolate/interpolate.py twice. (In this particular case that doesn't have any obviously bad side-effects, but the warning is still worrying, and it's easy to fix.)

~This PR moves the profiling script to its own module. To run the profiling script, run python -m scimath.interpolate.profile, which should now be warning-free.~

EDIT: Following discussion, this PR simply deletes the profiling code.

mdickinson commented 2 years ago

For context, here's the Python issue related to this particular warning: https://bugs.python.org/issue27487

mdickinson commented 2 years ago

Sigh: replaced scipy with scimath everywhere in the PR description.