Skip to content

Commit

Permalink
rename get_datalinks to locate_data following internal feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
zoghbi-a committed Jan 10, 2025
1 parent 1ce3523 commit 42ae40c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions astroquery/heasarc/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ def query_object(self, object_name, mission, *,
return self.query_region(pos, catalog=mission, spatial='cone',

Check warning on line 459 in astroquery/heasarc/core.py

View check run for this annotation

Codecov / codecov/patch

astroquery/heasarc/core.py#L458-L459

Added lines #L458 - L459 were not covered by tests
get_query_payload=get_query_payload)

def get_datalinks(self, query_result=None, catalog_name=None):
def locate_data(self, query_result=None, catalog_name=None):
"""Get links to data products
Use vo/datalinks to query the data products for some query_results.
Expand Down Expand Up @@ -578,7 +578,7 @@ def download_data(self, links, host='heasarc', location='.'):
Parameters
----------
links : `astropy.table.Table`
The result from get_datalinks
The result from locate_data
host : str
The data host. The options are: heasarc (default), sciserver, aws.
If host == 'sciserver', data is copied from the local mounted
Expand All @@ -605,7 +605,7 @@ def download_data(self, links, host='heasarc', location='.'):
if host_column not in links.colnames:
raise ValueError(
f'No {host_column} column found in the table. Call '
'~get_datalinks first'
'~locate_data first'
)

if host == 'heasarc':
Expand All @@ -632,7 +632,7 @@ def _download_heasarc(self, links, location='.'):
Parameters
----------
links : `astropy.table.Table`
The result from get_datalinks
The result from locate_data
location : str
local folder where the downloaded file will be saved.
Default is current working directory
Expand Down
10 changes: 5 additions & 5 deletions astroquery/heasarc/tests/test_heasarc.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,17 +256,17 @@ def test__list_columns(mock_tap, mock_default_cols):
assert list(cols['description']) == ['desc-2', 'desc-3']


def test_get_datalink():
def test_locate_data():
with pytest.raises(ValueError, match="query_result is None"):
Heasarc.get_datalinks()
Heasarc.locate_data()

with pytest.raises(
TypeError, match="query_result need to be an astropy.table.Table"
):
Heasarc.get_datalinks([1, 2])
Heasarc.locate_data([1, 2])

with pytest.raises(ValueError, match="No __row column found"):
Heasarc.get_datalinks(Table({"id": [1, 2, 3.0]}), catalog_name="xray")
Heasarc.locate_data(Table({"id": [1, 2, 3.0]}), catalog_name="xray")


def test_download_data__empty():
Expand All @@ -286,7 +286,7 @@ def test_download_data__missingcolumn(host):
host_col = "access_url" if host == "heasarc" else host
with pytest.raises(
ValueError,
match=f"No {host_col} column found in the table. Call ~get_datalinks first"
match=f"No {host_col} column found in the table. Call ~locate_data first"
):
Heasarc.download_data(Table({"id": [1]}), host=host)

Expand Down
8 changes: 4 additions & 4 deletions astroquery/heasarc/tests/test_heasarc_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,14 @@ def test__get_default_columns(self, tdefault):
remote_default = list(Heasarc._get_default_columns(catalog))
assert remote_default == tdef

def test_get_datalinks__wrongcatalog(self):
def test_locate_data__wrongcatalog(self):
with pytest.raises(ValueError, match="Unknown catalog name:"):
Heasarc.get_datalinks(
Heasarc.locate_data(
Table({"__row": [1, 2, 3.0]}), catalog_name="wrongcatalog"
)

def test_get_datalinks__xmmmaster(self):
links = Heasarc.get_datalinks(
def test_locate_data__xmmmaster(self):
links = Heasarc.locate_data(
Table({"__row": [4154, 4155]}), catalog_name="xmmmaster"
)
assert len(links) == 2
Expand Down
2 changes: 1 addition & 1 deletion docs/heasarc/heasarc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ with those results.
>>> from astropy.coordinates import SkyCoord
>>> pos = SkyCoord.from_name('ngc 3516')
>>> tab = Heasarc.query_region(pos, catalog='nicermastr')
>>> links = Heasarc.get_datalinks(tab[:2])
>>> links = Heasarc.locate_data(tab[:2])
>>> links.pprint(max_width=120)
ID access_url ... content_length
... byte
Expand Down

0 comments on commit 42ae40c

Please sign in to comment.