Skip to content

Commit 7de9084

Browse files
authored
Merge pull request #2153 from eerovaher/gaia-config-use
Fix the bug that caused `MAIN_GAIA_TABLE` in `astroquery.gaia` to not work
2 parents 8cdf185 + 561011f commit 7de9084

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

CHANGES.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ casda
1616
- Add ability to stage and download non image data which have been found
1717
through the CASDA obscore table. [#2158]
1818

19+
gaia
20+
^^^^
21+
22+
- The bug which caused changing the ``MAIN_GAIA_TABLE`` option to have no
23+
effect has been fixed [#2153]
24+
1925
vizier
2026
^^^^^^
2127

astroquery/gaia/core.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class GaiaClass(TapPlus):
3838
"""
3939
Proxy class to default TapPlus object (pointing to Gaia Archive)
4040
"""
41-
MAIN_GAIA_TABLE = conf.MAIN_GAIA_TABLE
41+
MAIN_GAIA_TABLE = None
4242
MAIN_GAIA_TABLE_RA = conf.MAIN_GAIA_TABLE_RA
4343
MAIN_GAIA_TABLE_DEC = conf.MAIN_GAIA_TABLE_DEC
4444
ROW_LIMIT = conf.ROW_LIMIT
@@ -426,7 +426,7 @@ def __query_object(self, coordinate, radius=None, width=None, height=None,
426426
dist ASC
427427
""".format(**{'row_limit': "TOP {0}".format(self.ROW_LIMIT) if self.ROW_LIMIT > 0 else "",
428428
'ra_column': self.MAIN_GAIA_TABLE_RA, 'dec_column': self.MAIN_GAIA_TABLE_DEC,
429-
'columns': columns, 'table_name': self.MAIN_GAIA_TABLE, 'ra': ra, 'dec': dec,
429+
'columns': columns, 'table_name': self.MAIN_GAIA_TABLE or conf.MAIN_GAIA_TABLE, 'ra': ra, 'dec': dec,
430430
'width': widthDeg.value, 'height': heightDeg.value})
431431
if async_job:
432432
job = self.launch_job_async(query, verbose=verbose)
@@ -486,7 +486,7 @@ def query_object_async(self, coordinate, radius=None, width=None,
486486
"""
487487
return self.__query_object(coordinate, radius, width, height, async_job=True, verbose=verbose, columns=columns)
488488

489-
def __cone_search(self, coordinate, radius, table_name=MAIN_GAIA_TABLE,
489+
def __cone_search(self, coordinate, radius, table_name=None,
490490
ra_column_name=MAIN_GAIA_TABLE_RA,
491491
dec_column_name=MAIN_GAIA_TABLE_DEC,
492492
async_job=False,
@@ -563,7 +563,7 @@ def __cone_search(self, coordinate, radius, table_name=MAIN_GAIA_TABLE,
563563
""".format(**{'ra_column': ra_column_name,
564564
'row_limit': "TOP {0}".format(self.ROW_LIMIT) if self.ROW_LIMIT > 0 else "",
565565
'dec_column': dec_column_name, 'columns': columns, 'ra': ra, 'dec': dec,
566-
'radius': radiusDeg, 'table_name': table_name})
566+
'radius': radiusDeg, 'table_name': table_name or self.MAIN_GAIA_TABLE or conf.MAIN_GAIA_TABLE})
567567

568568
if async_job:
569569
return self.launch_job_async(query=query,
@@ -580,7 +580,7 @@ def __cone_search(self, coordinate, radius, table_name=MAIN_GAIA_TABLE,
580580
dump_to_file=dump_to_file)
581581

582582
def cone_search(self, coordinate, radius=None,
583-
table_name=MAIN_GAIA_TABLE,
583+
table_name=None,
584584
ra_column_name=MAIN_GAIA_TABLE_RA,
585585
dec_column_name=MAIN_GAIA_TABLE_DEC,
586586
output_file=None,
@@ -631,7 +631,7 @@ def cone_search(self, coordinate, radius=None,
631631
dump_to_file=dump_to_file, columns=columns)
632632

633633
def cone_search_async(self, coordinate, radius=None,
634-
table_name=MAIN_GAIA_TABLE,
634+
table_name=None,
635635
ra_column_name=MAIN_GAIA_TABLE_RA,
636636
dec_column_name=MAIN_GAIA_TABLE_DEC,
637637
background=False,

astroquery/gaia/tests/test_gaiatap.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import os
1919
import pytest
2020

21+
from astroquery.gaia import conf
2122
from astroquery.gaia.core import GaiaClass
2223
from astroquery.gaia.tests.DummyTapHandler import DummyTapHandler
2324
from astroquery.utils.tap.conn.tests.DummyConnHandler import DummyConnHandler
@@ -344,6 +345,21 @@ def test_cone_search_async(self):
344345
None,
345346
np.int32)
346347

348+
# Regression test for #2093 and #2099 - changing the MAIN_GAIA_TABLE
349+
# had no effect.
350+
# The preceding tests should have used the default value.
351+
assert 'gaiadr2.gaia_source' in job.parameters['query']
352+
# Test changing the table name through conf.
353+
conf.MAIN_GAIA_TABLE = 'name_from_conf'
354+
job = tap.cone_search_async(sc, radius)
355+
assert 'name_from_conf' in job.parameters['query']
356+
# Changing the value through the class should overrule conf.
357+
tap.MAIN_GAIA_TABLE = 'name_from_class'
358+
job = tap.cone_search_async(sc, radius)
359+
assert 'name_from_class' in job.parameters['query']
360+
# Cleanup.
361+
conf.reset('MAIN_GAIA_TABLE')
362+
347363
def __check_results_column(self, results, columnName, description, unit,
348364
dataType):
349365
c = results[columnName]

0 commit comments

Comments
 (0)