Skip to content

Commit b555195

Browse files
committed
Hide CatalogCollection from user
1 parent b16163e commit b555195

3 files changed

Lines changed: 13 additions & 10 deletions

File tree

astroquery/mast/collections.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ def collection(self):
7272
"""
7373
The current MAST collection to be queried.
7474
"""
75-
return self._collection
75+
# Return the collection name instead of the object for easier user interaction,
76+
# but keep the object internally for API calls
77+
return self._collection.name
7678

7779
@collection.setter
7880
def collection(self, collection):
@@ -99,7 +101,7 @@ def catalog(self, catalog):
99101
"""
100102
Setter that verifies that the catalog is valid for the current collection.
101103
"""
102-
catalog = self.collection._verify_catalog(catalog)
104+
catalog = self._collection._verify_catalog(catalog)
103105
self._catalog = catalog
104106

105107
@property
@@ -147,7 +149,7 @@ def get_catalogs(self, collection=None):
147149
A table containing the available catalogs within the specified collection.
148150
"""
149151
# If no collection specified, use the class attribute
150-
collection_obj = self._get_collection_obj(collection) if collection else self.collection
152+
collection_obj = self._get_collection_obj(collection) if collection else self._collection
151153
return collection_obj.catalogs
152154

153155
@class_or_instance
@@ -924,7 +926,7 @@ def _parse_inputs(self, collection=None, catalog=None):
924926
tuple
925927
A tuple containing the (collection, catalog) to be queried.
926928
"""
927-
collection_obj = self._get_collection_obj(collection) if collection else self.collection
929+
collection_obj = self._get_collection_obj(collection) if collection else self._collection
928930

929931
if not catalog:
930932
# If the class attribute catalog is valid for the collection, use it

astroquery/mast/tests/test_mast.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1477,7 +1477,8 @@ def test_catalogs_attributes(patch_tap):
14771477
offset=1,
14781478
sort_by="ra",
14791479
)
1480-
assert isinstance(Catalogs.collection, CatalogCollection)
1480+
# Should not change after query
1481+
assert Catalogs.collection == "hsc"
14811482
assert Catalogs.catalog == "dbo.SumMagAper2CatView"
14821483

14831484

astroquery/mast/tests/test_mast_remote.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,22 +1056,22 @@ def test_observations_get_cloud_uris_no_duplicates(self, msa_product_table, rese
10561056
def test_catalogs_collection(self):
10571057
# Default collection should be HSC
10581058
c = Catalogs()
1059-
assert c.collection.name == "hsc"
1059+
assert c.collection == "hsc"
10601060
assert c.catalog == "dbo.SumMagAper2CatView"
10611061

10621062
# Initialize with a different collection
10631063
c = Catalogs(collection="gaiadr3")
1064-
assert c.collection.name == "gaiadr3"
1064+
assert c.collection == "gaiadr3"
10651065
assert c.catalog == "dbo.gaia_source"
10661066

10671067
# Initialize with a different collection and catalog
10681068
c = Catalogs(collection="ullyses", catalog="publications")
1069-
assert c.collection.name == "ullyses"
1069+
assert c.collection == "ullyses"
10701070
assert c.catalog == "dbo.publications"
10711071

10721072
# Set the collection
10731073
c.collection = "caom"
1074-
assert c.collection.name == "caom"
1074+
assert c.collection == "caom"
10751075
assert c.catalog == "dbo.obspointing"
10761076

10771077
def test_catalogs_get_collections(self):
@@ -1229,7 +1229,7 @@ def test_catalogs_query_region(self):
12291229

12301230
# Region search with circle
12311231
result = Catalogs.query_region(
1232-
collection="caom", region="CIRCLE ICRS 18.85 -6.95 0.1", limit=5, select_cols=select_cols
1232+
collection="caom", region="CIRCLE ICRS 18.85 -6.95 0.01", limit=5, select_cols=select_cols
12331233
)
12341234
assert isinstance(result, Table)
12351235
assert len(result) <= 5

0 commit comments

Comments
 (0)