diff --git a/python/lsst/daf/butler/_dataset_type.py b/python/lsst/daf/butler/_dataset_type.py index e9ba515ef9..c7b546cc94 100644 --- a/python/lsst/daf/butler/_dataset_type.py +++ b/python/lsst/daf/butler/_dataset_type.py @@ -676,7 +676,7 @@ def to_simple(self, minimal: bool = False) -> SerializedDatasetType: "name": self.name, "storageClass": self._storageClassName, "isCalibration": self._isCalibration, - "dimensions": list(self._dimensions.required), + "dimensions": list(self._dimensions.names), } if self._parentStorageClassName is not None: diff --git a/python/lsst/daf/butler/dimensions/_coordinate.py b/python/lsst/daf/butler/dimensions/_coordinate.py index d511a49cac..d6f4189e9c 100644 --- a/python/lsst/daf/butler/dimensions/_coordinate.py +++ b/python/lsst/daf/butler/dimensions/_coordinate.py @@ -709,7 +709,7 @@ def to_simple(self, minimal: bool = False) -> SerializedDataCoordinate: else: records = None - return SerializedDataCoordinate(dataId=dict(self.required), records=records) + return SerializedDataCoordinate(dataId=dict(self.mapping), records=records) @classmethod def from_simple( diff --git a/python/lsst/daf/butler/tests/butler_queries.py b/python/lsst/daf/butler/tests/butler_queries.py index 0410afcef5..64aaa1bbb8 100644 --- a/python/lsst/daf/butler/tests/butler_queries.py +++ b/python/lsst/daf/butler/tests/butler_queries.py @@ -303,6 +303,18 @@ def test_simple_dataset_query(self) -> None: butler.query_datasets("bias", "*", detector=100, instrument="Unknown", find_first=False) self.assertIn("doomed", str(cm2.exception)) + # Test for a regression of an issue where "band" was not being included + # in the data ID, despite being one of the dimensions in the "flat" + # dataset type. + refs = butler.query_datasets("flat", "imported_r", where="detector = 2", instrument="Cam1") + self.assertEqual(len(refs), 1) + flat = refs[0] + self.assertEqual(flat.datasetType.name, "flat") + self.assertEqual(flat.dataId["instrument"], "Cam1") + self.assertEqual(flat.dataId["detector"], 2) + self.assertEqual(flat.dataId["physical_filter"], "Cam1-R1") + self.assertEqual(flat.dataId["band"], "r") + def test_general_query(self) -> None: """Test Query.general and its result.""" butler = self.make_butler("base.yaml", "datasets.yaml")