Skip to content

Commit 650e2eb

Browse files
committed
improve behavior, make more clear keyword, fix incorrect documentation, and add changelog entry
1 parent 868772e commit 650e2eb

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

CHANGES.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ alma
1919

2020
- Bug fix in ``footprint_to_reg`` that did not allow regions to be plotted. [#3285]
2121

22+
linelists.cdms
23+
^^^^^^^^^^^^^^
24+
25+
- Add a keyword to control writing of new species cache files. This is needed to prevent tests from overwriting those files. [#3300]
26+
2227
heasarc
2328
^^^^^^^
2429

astroquery/linelists/cdms/core.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from astroquery.linelists.cdms import conf
1414
from astroquery.exceptions import InvalidQueryError, EmptyResponseError
1515

16+
import warnings
1617
import re
1718
import string
1819

@@ -295,7 +296,7 @@ def _parse_result(self, response, *, verbose=False):
295296
def get_species_table(self, *, catfile='partfunc.cat', use_cached=True,
296297
catfile_url=conf.catfile_url,
297298
catfile2='catdir.cat', catfile_url2=conf.catfile_url2,
298-
write=True):
299+
write_new_species_cache=True):
299300
"""
300301
A directory of the catalog is found in a file called 'catdir.cat.'
301302
@@ -308,10 +309,11 @@ def get_species_table(self, *, catfile='partfunc.cat', use_cached=True,
308309
use_cached : bool, optional
309310
If True, use the cached file if it exists. If False, download the
310311
file from the CDMS server and save it to the cache (if ``write`` is set).
311-
write : bool, optional
312-
If True, and if ``use_cached`` is set, write the file to the cache. Use this
313-
option if you need to update the index from CDMS; this should be set to False
314-
for testing.
312+
write_new_species_cache : bool, optional
313+
If True, and if ``use_cached`` is False, write the species data
314+
table files to the CDMS data directory. Use this option if you need
315+
to update the index from CDMS; this should be set to False for
316+
testing.
315317
316318
Returns
317319
-------
@@ -325,6 +327,8 @@ def get_species_table(self, *, catfile='partfunc.cat', use_cached=True,
325327
"""
326328

327329
if use_cached:
330+
if write_new_species_cache:
331+
warnings.warn("use_cached and write_new_species_cache are both set to True; write_new_species_cache will be ignored. If you meant to update the cache, set use_cached to False.")
328332
try:
329333
result = ascii.read(data_path(catfile), format='fixed_width', delimiter='|')
330334
result2 = ascii.read(data_path(catfile2), format='fixed_width', delimiter='|')
@@ -340,7 +344,7 @@ def get_species_table(self, *, catfile='partfunc.cat', use_cached=True,
340344
else:
341345
result = retrieve_catfile(catfile_url)
342346
result2 = retrieve_catfile2(catfile_url2)
343-
if write:
347+
if write_new_species_cache:
344348
result.write(data_path(catfile), format='ascii.fixed_width', delimiter='|', overwrite=True)
345349
result2.write(data_path(catfile2), format='ascii.fixed_width', delimiter='|', overwrite=True)
346350

0 commit comments

Comments
 (0)