spedas / pyspedas

Python-based Space Physics Environment Data Analysis Software
https://pyspedas.readthedocs.io/
MIT License
143 stars 58 forks source link

ELFIN test_epd_calibration failing...is there a missing file? #901

Closed jameswilburlewis closed 3 days ago

jameswilburlewis commented 1 week ago

I think the intention was for the calibration file to be included under the pyspedas.elfin.tests module:

But the test code to load it isn't working:

    def test_read_epde_calibration_data(self):
        with importlib.resources.path("pyspedas.elfin.tests", "test_dataset/test_epde_cal_data.txt") as test_file_path:
            self.assertListEqual(read_epde_calibration_data(test_file_path), EXPECTED_EPDE_CAL_DATA)

But the test code to load it isn't working: Python is complaining that there should be just a filename instead of the path test_dataset/test_epde_cal_data.txt .

  File "/Users/jwl/PycharmProjects/pyspedas/pyspedas/elfin/tests/test_epd_calibration.py", line 69, in test_read_epde_calibration_data
    with importlib.resources.path("pyspedas.elfin.tests", "test_dataset/test_epde_cal_data.txt") as test_file_path:
  File "/Users/jwl/anaconda3/envs/pycharm_py39/lib/python3.9/contextlib.py", line 119, in __enter__
    return next(self.gen)
  File "/Users/jwl/anaconda3/envs/pycharm_py39/lib/python3.9/importlib/resources.py", line 171, in _path_from_reader
    norm_resource = _normalize_path(resource)
  File "/Users/jwl/anaconda3/envs/pycharm_py39/lib/python3.9/importlib/resources.py", line 62, in _normalize_path
    raise ValueError('{!r} must be only a file name'.format(path))
ValueError: 'test_dataset/test_epde_cal_data.txt' must be only a file name

But there's no file by that name anywhere under the elfin directory. The cal file should either be checked into github and the importlib statement adjusted to find it, or downloaded on the fly and read from the ELFIN data directory somewhere.