Skip to content

Commit 403a5d7

Browse files
authored
Merge pull request #2655 from nkphysics/nist-kwarg-refactor
Refactor: Make NIST keyword only
2 parents 36b2a4e + 98bad54 commit 403a5d7

File tree

5 files changed

+12
-7
lines changed

5 files changed

+12
-7
lines changed

CHANGES.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@ mast
145145
- Expanding ``Cutouts`` functionality to support making Hubble Advanced Product (HAP)
146146
cutouts via HAPCut. [#2613]
147147

148+
nist
149+
^^^^
150+
151+
- Optional parameters in all methods are kwargs keyword only. [#2655]
152+
148153
oac
149154
^^^
150155

astroquery/nist/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def _args_to_payload(self, *args, **kwargs):
125125
return request_payload
126126

127127
@prepend_docstr_nosections("\n" + _args_to_payload.__doc__)
128-
def query_async(self, minwav, maxwav, linename="H I",
128+
def query_async(self, minwav, maxwav, *, linename="H I",
129129
energy_level_unit='eV', output_order='wavelength',
130130
wavelength_type='vacuum', get_query_payload=False):
131131
"""
@@ -145,7 +145,7 @@ def query_async(self, minwav, maxwav, linename="H I",
145145
timeout=Nist.TIMEOUT)
146146
return response
147147

148-
def _parse_result(self, response, verbose=False):
148+
def _parse_result(self, response, *, verbose=False):
149149
"""
150150
Parses the results from the HTTP response to `astropy.table.Table`.
151151

astroquery/nist/tests/test_nist.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ def test_parse_wavelength():
4242

4343
def test_query_async(patch_get):
4444
response = nist.core.Nist.query_async(4000 * u.nm, 7000 * u.nm,
45-
"H I", get_query_payload=True)
45+
linename="H I", get_query_payload=True)
4646
assert response['spectra'] == "H I"
4747
assert response['unit'] == nist.core.Nist.unit_code['nm']
48-
response = nist.core.Nist.query_async(4000 * u.nm, 7000 * u.nm, "H I")
48+
response = nist.core.Nist.query_async(4000 * u.nm, 7000 * u.nm, linename="H I")
4949
assert response is not None
5050

5151

5252
def test_query(patch_get):
53-
result = nist.core.Nist.query(4000 * u.nm, 7000 * u.nm, "H I")
53+
result = nist.core.Nist.query(4000 * u.nm, 7000 * u.nm, linename="H I")
5454
assert isinstance(result, Table)

astroquery/nist/tests/test_nist_remote.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def test_query(self):
2424
assert set(result['TP']) == set(['T8637', 'T7771'])
2525

2626
def test_unescape_html(self):
27-
response = nist.core.Nist.query_async(4333 * u.AA, 4334 * u.AA, "V I")
27+
response = nist.core.Nist.query_async(4333 * u.AA, 4334 * u.AA, linename="V I")
2828
assert '†' in response.text
2929
# check that Unicode characters have been properly unescaped from their
3030
# raw HTML code equivalents during parsing

docs/nist/nist.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ or 'vac+air'. Here is an example with all these parameters.
6969
.. doctest-remote-data::
7070

7171
>>> from astroquery.nist import Nist
72-
>>> table = Nist.query(4000 * u.nm, 7000 * u.nm, 'H I',
72+
>>> table = Nist.query(4000 * u.nm, 7000 * u.nm, linename='H I',
7373
... energy_level_unit='eV', output_order='wavelength',
7474
... wavelength_type='vacuum')
7575
>>> print(table)

0 commit comments

Comments
 (0)