Import problem for the subtract_median testing #1002
Labels
python
Issues involving Python and Python-related tools outside of pyspedas
pytplot
Issues involving the pytplot package
QA/Testing
I'm extending the test coverage for the
subtract_average
andsubtract_median
functions. Sincesubtract_median
essentially wraps aroundsubtract_average
, I aim to create a test to verify ifsubtract_median
correctly callssubtract_average
with the appropriate parameters.Here’s the intended test structure:
However, this test fails due to how
subtract_median
importssubtract_average
:Here’s the problem:
subtract_average.py
is in thetplot_math
package, which itself is part ofpytplot
. Thetplot_math
package's__init__.py
file imports both functions as follows:This enables users to import the functions like:
instead of:
However, when
subtract_median
internally callssubtract_average
, it uses the full path:pytplot.tplot_math.subtract_average.subtract_average
, not the simplified pathpytplot.tplot_math.subtract_average
.Due to this, the test fails:
patch('pytplot.tplot_math.subtract_average.subtract_average')
fails because the firstsubtract_average
is already identified as a function due to the__init__.py
structure.patch('pytplot.tplot_math.subtract_average')
does not work either because withinsubtract_median
, the function is actually referenced aspytplot.tplot_math.subtract_average.subtract_average
.This indicates either a misunderstanding of the Python import system on my part or a potential issue with how the
pytplot
import structure is currently organized.Important
With the reorganization of
pyspedas
into separateprojects
, this import behavior may lead to conflicts similar to the one described above.The text was updated successfully, but these errors were encountered: