From ec77bce03b9306f56a85fc7bfa65480b3c07b437 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= <bsipocz@gmail.com>
Date: Mon, 17 Mar 2025 11:58:09 -0700
Subject: [PATCH 1/2] ENH: returning QTable for Alma.query_sia

---
 astroquery/alma/core.py            | 8 +++++---
 astroquery/alma/tests/test_alma.py | 6 ++++--
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/astroquery/alma/core.py b/astroquery/alma/core.py
index f6bcf76971..9ad01fac62 100644
--- a/astroquery/alma/core.py
+++ b/astroquery/alma/core.py
@@ -652,10 +652,10 @@ def query_sia(self, *, pos=None, band=None, time=None, pol=None,
 
         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(
+        results = self.sia.search(
             pos=pos,
             band=band,
             time=time,
@@ -676,6 +676,8 @@ def query_sia(self, *, pos=None, band=None, time=None, pol=None,
             maxrec=maxrec,
             **kwargs)
 
+        return results.to_qtable()
+
     query_sia.__doc__ = query_sia.__doc__.replace('_SIA2_PARAMETERS', SIA2_PARAMETERS_DESC)
 
     def query_tap(self, query, *, maxrec=None, uploads=None):
diff --git a/astroquery/alma/tests/test_alma.py b/astroquery/alma/tests/test_alma.py
index 6bbdc50911..27e0cd6040 100644
--- a/astroquery/alma/tests/test_alma.py
+++ b/astroquery/alma/tests/test_alma.py
@@ -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_qtable.return_value = empty_result
+    sia_mock.search.return_value = mock_result
     alma = Alma()
     alma._get_dataarchive_url = Mock()
     alma._sia = sia_mock
@@ -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',

From 02fda1322c274ed361bf179de766d9e72061cc3e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= <bsipocz@gmail.com>
Date: Mon, 17 Mar 2025 12:14:08 -0700
Subject: [PATCH 2/2] Adding enhanced_results to Alma.query_sia

---
 astroquery/alma/core.py            | 12 +++++++++---
 astroquery/alma/tests/test_alma.py |  2 +-
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/astroquery/alma/core.py b/astroquery/alma/core.py
index 9ad01fac62..fddd8ad2dd 100644
--- a/astroquery/alma/core.py
+++ b/astroquery/alma/core.py
@@ -642,7 +642,7 @@ def query_sia(self, *, pos=None, band=None, time=None, pol=None,
                   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.
 
@@ -655,7 +655,7 @@ def query_sia(self, *, pos=None, band=None, time=None, pol=None,
         Results in `~astropy.table.QTable` format.
 
         """
-        results = self.sia.search(
+        result = self.sia.search(
             pos=pos,
             band=band,
             time=time,
@@ -676,7 +676,13 @@ def query_sia(self, *, pos=None, band=None, time=None, pol=None,
             maxrec=maxrec,
             **kwargs)
 
-        return results.to_qtable()
+        if result is not None:
+            if enhanced_results:
+                result = get_enhanced_table(result)
+            else:
+                result = result.to_table()
+
+        return result
 
     query_sia.__doc__ = query_sia.__doc__.replace('_SIA2_PARAMETERS', SIA2_PARAMETERS_DESC)
 
diff --git a/astroquery/alma/tests/test_alma.py b/astroquery/alma/tests/test_alma.py
index 27e0cd6040..ac9683960f 100644
--- a/astroquery/alma/tests/test_alma.py
+++ b/astroquery/alma/tests/test_alma.py
@@ -465,7 +465,7 @@ def test_sia():
     empty_result = Table.read(os.path.join(DATA_DIR, 'alma-empty.txt'),
                               format='ascii')
     mock_result = Mock()
-    mock_result.to_qtable.return_value = empty_result
+    mock_result.to_table.return_value = empty_result
     sia_mock.search.return_value = mock_result
     alma = Alma()
     alma._get_dataarchive_url = Mock()