Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

freeze degree string representation #2347

Merged
merged 3 commits into from
Mar 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion astroquery/heasarc/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,11 @@ def query_region_async(self, position: Union[coordinates.SkyCoord, str],
kwargs['equinox'] = 2000

# Generate the request
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you may want to leave a one-liner comment as a reminder why formatting is applied here, otherwise it's likely someone would wonder a few years down the line 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, done. I did not manage in one line, only two, but if you have better ideas - please suggest!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

multi-liner is fine, too, I just meant that it can be just a very short reminder :)

# Fixed string representation of coordinates ensures that request payload
# does not depend on python/astropy version for the same input coordinates
request_payload = self._args_to_payload(
mission=mission,
entry="{},{}".format(c.ra.degree, c.dec.degree),
entry=f"{c.ra.degree:.10f},{c.dec.degree:.10f}",
radius=u.Quantity(radius),
**kwargs
)
Expand Down
7 changes: 6 additions & 1 deletion astroquery/heasarc/tests/parametrization.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
import os
import glob
import hashlib
Expand Down Expand Up @@ -40,7 +41,11 @@ def fileid_for_request(url, params):

def filename_for_request(url, params, output=False):
fileid = fileid_for_request(url, params)
return data_path(fileid, output=output)

filename = data_path(fileid, output=output)
log.debug(f'constructed filename {filename} for request: ' + json.dumps(dict(url=url, params=params), sort_keys=True, indent=4))

return filename


def get_mockreturn(session, method, url, params=None, timeout=10, **kwargs):
Expand Down
1 change: 1 addition & 0 deletions astroquery/heasarc/tests/test_heasarc_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def test_custom_args(self):
time="2020-09-01 .. 2020-12-01",
resultmax=10,
good_isgri=">1000",
cache=False
)

def test_filter_custom_args(self):
Expand Down
1 change: 1 addition & 0 deletions astroquery/heasarc/tests/test_heasarc_remote_isdc.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def test_custom_args(self):
time="2020-09-01 .. 2020-12-01",
resultmax=10,
good_isgri=">1000",
cache=False
)

def test_filter_custom_args(self):
Expand Down