Skip to content

Commit 82ef89b

Browse files
keflavichbsipocz
authored andcommitted
change 'regex_str' to 'species_regex'
1 parent 78274f5 commit 82ef89b

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

astroquery/splatalogue/build_species_table.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ def get_json_species_ids(*, outfile='splat-species.json', base_url=conf.base_url
6767
species[kid['class'][0]][kid['value']] = kid.text
6868

6969
with open(data_path(outfile), 'w') as f:
70-
assert isinstance(species, dict)
7170
json.dump(species, f)
7271

7372
return json.dumps(species)

astroquery/splatalogue/core.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,17 @@ def set_default_options(self, **kwargs):
7676
"""
7777
self.data.update(self._parse_kwargs(**kwargs))
7878

79-
def get_species_ids(self, regex_str=None, *, reflags=0, recache=False):
79+
def get_species_ids(self, species_regex=None, *, reflags=0, recache=False):
8080
"""
8181
Get a dictionary of "species" IDs, where species refers to the molecule
8282
name, mass, and chemical composition.
8383
8484
Parameters
8585
----------
86-
regex_str : str
87-
String to compile into an re, if specified. Searches table for
88-
species whose names match
86+
species_regex : str
87+
String to search for among the species names, if specified.
88+
The string will be compiled into a regular expression using the
89+
python `re` module.
8990
reflags : int
9091
Flags to pass to `re`.
9192
recache : bool
@@ -95,7 +96,7 @@ def get_species_ids(self, regex_str=None, *, reflags=0, recache=False):
9596
--------
9697
>>> import re
9798
>>> import pprint # unfortunate hack required for documentation testing
98-
>>> rslt = Splatalogue.get_species_ids(regex_str='Formaldehyde')
99+
>>> rslt = Splatalogue.get_species_ids(species_regex='Formaldehyde')
99100
>>> pprint.pprint(rslt)
100101
{'03023 H2CO - Formaldehyde': '194',
101102
'03106 H213CO - Formaldehyde': '324',
@@ -107,7 +108,7 @@ def get_species_ids(self, regex_str=None, *, reflags=0, recache=False):
107108
'03301 D213CO - Formaldehyde': '1220',
108109
'03315 HDC18O - Formaldehyde': '21141',
109110
'03410 D2C18O - Formaldehyde': '21140'}
110-
>>> rslt = Splatalogue.get_species_ids(regex_str='H2CO')
111+
>>> rslt = Splatalogue.get_species_ids(species_regex='H2CO')
111112
>>> pprint.pprint(rslt)
112113
{'03023 H2CO - Formaldehyde': '194',
113114
'03109 H2COH+ - Hydroxymethylium ion': '224',
@@ -125,9 +126,9 @@ def get_species_ids(self, regex_str=None, *, reflags=0, recache=False):
125126
'08903 CH3CHNH2COOH - II - α-Alanine': '1322'}
126127
>>> # note the whitespace, preventing H2CO within other
127128
>>> # more complex molecules
128-
>>> Splatalogue.get_species_ids(regex_str=' H2CO ')
129+
>>> Splatalogue.get_species_ids(species_regex=' H2CO ')
129130
{'03023 H2CO - Formaldehyde': '194'}
130-
>>> Splatalogue.get_species_ids(regex_str=' h2co ', reflags=re.IGNORECASE)
131+
>>> Splatalogue.get_species_ids(species_regex=' h2co ', reflags=re.IGNORECASE)
131132
{'03023 H2CO - Formaldehyde': '194'}
132133
133134
"""
@@ -136,8 +137,8 @@ def get_species_ids(self, regex_str=None, *, reflags=0, recache=False):
136137
if not hasattr(self, '_species_ids'):
137138
self._species_ids = load_species_table.species_lookuptable(recache=recache)
138139

139-
if regex_str is not None:
140-
return self._species_ids.find(regex_str, flags=reflags)
140+
if species_regex is not None:
141+
return self._species_ids.find(species_regex, flags=reflags)
141142
else:
142143
return self._species_ids
143144

@@ -319,7 +320,7 @@ def _parse_kwargs(self, *, min_frequency=None, max_frequency=None,
319320
payload['sid[]'] = []
320321
elif chemical_name is not None:
321322
if parse_chemistry_locally:
322-
species_ids = self.get_species_ids(regex_str=chemical_name, reflags=chem_re_flags)
323+
species_ids = self.get_species_ids(species_regex=chemical_name, reflags=chem_re_flags)
323324
if len(species_ids) == 0:
324325
raise ValueError("No matching chemical species found.")
325326
payload['sid[]'] = list(species_ids.values())

docs/splatalogue/splatalogue.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ To search within this list for a particular species, you can use regular express
2929

3030
.. code-block:: python
3131
32-
>>> CO_containing_species = Splatalogue.get_species_ids(regex_str='CO')
32+
>>> CO_containing_species = Splatalogue.get_species_ids(species_regex='CO')
3333
>>> len(CO_containing_species)
3434
105
35-
>>> just_CO = Splatalogue.get_species_ids(regex_str=' CO ') # note the spaces
35+
>>> just_CO = Splatalogue.get_species_ids(species_regex=' CO ') # note the spaces
3636
>>> len(just_CO)
3737
4
3838
>>> assert just_CO == {'02812 CO v = 0 - Carbon Monoxide': '204',

0 commit comments

Comments
 (0)