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

ENH: returning (Q)Table for Alma.query_sia #3261

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
16 changes: 12 additions & 4 deletions astroquery/alma/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@
instrument=None, data_type=None,
calib_level=None, target_name=None,
res_format=None, maxrec=None,
**kwargs):
enhanced_results=False, **kwargs):
"""
Use standard SIA2 attributes to query the ALMA SIA service.

Expand All @@ -652,10 +652,10 @@

Returns
-------
Results in `~pyvo.dal.sia2.SIA2Results` format.
result.to_qtable in `~astropy.table.QTable` format
Results in `~astropy.table.QTable` format.

"""
return self.sia.search(
result = self.sia.search(
pos=pos,
band=band,
time=time,
Expand All @@ -676,6 +676,14 @@
maxrec=maxrec,
**kwargs)

if result is not None:
if enhanced_results:
result = get_enhanced_table(result)

Check warning on line 681 in astroquery/alma/core.py

View check run for this annotation

Codecov / codecov/patch

astroquery/alma/core.py#L681

Added line #L681 was not covered by tests
else:
result = result.to_table()

return result

query_sia.__doc__ = query_sia.__doc__.replace('_SIA2_PARAMETERS', SIA2_PARAMETERS_DESC)

def query_tap(self, query, *, maxrec=None, uploads=None):
Expand Down
6 changes: 4 additions & 2 deletions astroquery/alma/tests/test_alma.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,9 @@ def test_sia():
sia_mock = Mock()
empty_result = Table.read(os.path.join(DATA_DIR, 'alma-empty.txt'),
format='ascii')
sia_mock.search.return_value = Mock(table=empty_result)
mock_result = Mock()
mock_result.to_table.return_value = empty_result
sia_mock.search.return_value = mock_result
alma = Alma()
alma._get_dataarchive_url = Mock()
alma._sia = sia_mock
Expand All @@ -477,7 +479,7 @@ def test_sia():
target_name='J0423-013',
publisher_did='ADS/JAO.ALMA#2013.1.00546.S',
exptime=25)
assert len(result.table) == 0
assert len(result) == 0
assert_called_with(sia_mock.search, calib_level=[0, 1],
band=(300, 400), data_type='cube',
pos='CIRCLE 1 2 1',
Expand Down
Loading