Closed taldcroft closed 1 year ago
I think this is great!
But I ran into an issue from the last PR #385 that I'm surprised passes tests:
(ska3) spark:proseco jean$ ipython
Python 3.10.8 | packaged by conda-forge | (main, Nov 22 2022, 08:27:35) [Clang 14.0.6 ]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.8.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import proseco.tests.test_catalog
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[1], line 1
----> 1 import proseco.tests.test_catalog
File ~/git/proseco/proseco/tests/test_catalog.py:21
18 from .test_common import DARK40, OBS_INFO, STD_INFO, mod_std_info
20 # Ensure all plotting is to a non-interactive backend
---> 21 matplotlib.pyplot.switch_backend("agg")
23 HAS_SC_ARCHIVE = Path(mica.starcheck.starcheck.FILES["data_root"]).exists()
24 TEST_COLS = "slot idx id type sz yang zang dim res halfw".split()
File ~/miniconda3/envs/ska3/lib/python3.10/site-packages/matplotlib/_api/__init__.py:224, in caching_module_getattr.<locals>.__getattr__(name)
222 if name in props:
223 return props[name].__get__(instance)
--> 224 raise AttributeError(
225 f"module {cls.__module__!r} has no attribute {name!r}")
AttributeError: module 'matplotlib' has no attribute 'pyplot'
Granted, I guess it doesn't really matter because the tests aren't meant to be run that way anyway... they need their pytest magics.
I wasn't sure if that "auto-import" of pyplot would work when I first wrote the code, but I thought that getting through pytest was a sufficient demonstration. Huh, magics indeed. Anyway, fixed.
Description
This improves the implementation of
proseco.characteristics
(commonlyACA
in the code) so that the characteristics that are derived from the chandra_modelsaca_spec.json
thermal model spec always reflect the correct values. This applies even when environment variables likeCHANDRA_MODELS_REPO_DIR
are changed during program execution.Previously the values were cached based on the selected repo and version at the first time the characteristics were accessed. The test which changed illustrates how things work more nicely now, in particular no need for explicitly dealing with caching.
Thanks to @jeanconn in https://github.com/sot/proseco/pull/385#pullrequestreview-1579028964 for pointing out this possibility.
Interface impacts
None.
Testing
Unit tests
Independent check of unit tests by Jean
Functional tests
No functional testing.