DimensionRecordSet¶
- final class lsst.daf.butler.DimensionRecordSet(element: DimensionElement | str, records: Iterable[DimensionRecord] = (), universe: DimensionUniverse | None = None, *, _by_required_values: dict[tuple[DataIdValue, ...], DimensionRecord] | None = None)¶
- Bases: - Collection[- DimensionRecord]- A mutable set-like container specialized for - DimensionRecordobjects.- Parameters:
- elementDimensionElementorstr, optional
- The dimension element that defines the records held by this set. If not a - DimensionElementinstance,- universemust be provided.
- recordsIterable[DimensionRecord], optional
- Dimension records to add to the set. 
- universeDimensionUniverse, optional
- Object that defines all dimensions. Ignored if - elementis a- DimensionElementinstance.
 
- element
 - Notes - DimensionRecordSetmaintains its insertion order (like- dict, and unlike- set).- DimensionRecordSetimplements- collections.abc.Collectionbut not- collections.abc.Setbecause the latter would require interoperability with all other- Setimplementations rather than just- DimensionRecordSet, and that adds a lot of complexity without much clear value. To help make this clear to type checkers it implements only the named-method versions of these operations (e.g.- issubset) rather than the operator special methods (e.g.- __le__).- DimensionRecordequality is defined in terms of a record’s data ID fields only, and- DimensionRecordSetdoes not generally specify which record “wins” when two records with the same data ID interact (e.g. in- intersection). The- addand- updatemethods are notable exceptions: they always replace the existing record with the new one.- Dimension records can also be held by - DimensionRecordTable, which provides column-oriented access and Arrow interoperability.- Attributes Summary - Name of the dimension element these records correspond to. - Methods Summary - add(value[, replace])- Add a new record to the set. - difference(other)- Return a new set with only records that are in - selfand not in- other.- discard(value)- Remove a record if it exists. - find(data_id[, or_add])- Return the record with the given data ID. - find_with_required_values(required_values[, ...])- Return the record whose data ID has the given required values. - intersection(other)- Return a new set with only records that are in both - selfand- other.- isdisjoint(other)- Test whether the intersection of - selfand- otheris empty.- issubset(other)- Test whether all elements in - selfare in- other.- issuperset(other)- Test whether all elements in - otherare in- self.- pop()- Remove and return an arbitrary record. - remove(value)- Remove a record. - union(other)- Return a new set with all records that are either in - selfor- other.- update(values[, replace])- Add new records to the set. - update_from_data_coordinates(data_coordinates)- Add records to the set by extracting and deduplicating them from data coordinates. - Attributes Documentation - element¶
- Name of the dimension element these records correspond to. 
 - Methods Documentation - add(value: DimensionRecord, replace: bool = True) None¶
- Add a new record to the set. - Parameters:
- valueDimensionRecord
- Record to add. 
- replacebool, optional
- If - True(default) replace any existing record with the same data ID. If- Falsethe existing record will be kept.
 
- value
- Raises:
- ValueError
- Raised if - value.element != self.element.
 
 
 - difference(other: DimensionRecordSet) DimensionRecordSet¶
- Return a new set with only records that are in - selfand not in- other.- Parameters:
- otherDimensionRecordSet
- Another record set with the same record type. 
 
- other
- Returns:
- differenceDimensionRecordSet
- A new record set with all elements - selfthat are not in- other.
 
- difference
 
 - discard(value: DimensionRecord | DataCoordinate) None¶
- Remove a record if it exists. - Parameters:
- valueDimensionRecordorDataCoordinate
- Record to remove, or its data ID. 
 
- value
 
 - find(data_id: ~lsst.daf.butler.dimensions._coordinate.DataCoordinate, or_add: ~lsst.daf.butler.dimensions._record_set.DimensionRecordFactory = <function fail_record_lookup>) DimensionRecord¶
- Return the record with the given data ID. - Parameters:
- data_idDataCoordinate
- Data ID to match. 
- or_addDimensionRecordFactory
- Callback that is invoked if no existing record is found, to create a new record that is added to the set and returned. The return value of this callback is not checked to see if it is a valid dimension record with the right element and data ID. 
 
- data_id
- Returns:
- recordDimensionRecord
- Matching record. 
 
- record
- Raises:
- KeyError
- Raised if no record with this data ID was found. 
- ValueError
- Raised if the data ID did not have the right dimensions. 
 
 
 - find_with_required_values(required_values: tuple[int | str | None, ...], or_add: ~lsst.daf.butler.dimensions._record_set.DimensionRecordFactory = <function fail_record_lookup>) DimensionRecord¶
- Return the record whose data ID has the given required values. - Parameters:
- required_valuestuple[intorstr]
- Data ID values to match. 
- or_addDimensionRecordFactory
- Callback that is invoked if no existing record is found, to create a new record that is added to the set and returned. The return value of this callback is not checked to see if it is a valid dimension record with the right element and data ID. 
 
- required_values
- Returns:
- recordDimensionRecord
- Matching record. 
 
- record
- Raises:
- ValueError
- Raised if the data ID did not have the right dimensions. 
 
 
 - intersection(other: DimensionRecordSet) DimensionRecordSet¶
- Return a new set with only records that are in both - selfand- other.- Parameters:
- otherDimensionRecordSet
- Another record set with the same record type. 
 
- other
- Returns:
- intersectionDimensionRecordSet
- A new record set with all elements in both sets. 
 
- intersection
 
 - isdisjoint(other: DimensionRecordSet) bool¶
- Test whether the intersection of - selfand- otheris empty.- Parameters:
- otherDimensionRecordSet
- Another record set with the same record type. 
 
- other
- Returns:
- isdisjoint ; bool
- Whether the intersection of - selfand- otheris empty.
 
- isdisjoint ; 
 
 - issubset(other: DimensionRecordSet) bool¶
- Test whether all elements in - selfare in- other.- Parameters:
- otherDimensionRecordSet
- Another record set with the same record type. 
 
- other
- Returns:
- issubset ; bool
- Whether all elements in - selfare in- other.
 
- issubset ; 
 
 - issuperset(other: DimensionRecordSet) bool¶
- Test whether all elements in - otherare in- self.- Parameters:
- otherDimensionRecordSet
- Another record set with the same record type. 
 
- other
- Returns:
- issuperset ; bool
- Whether all elements in - otherare in- self.
 
- issuperset ; 
 
 - pop() DimensionRecord¶
- Remove and return an arbitrary record. 
 - remove(value: DimensionRecord | DataCoordinate) None¶
- Remove a record. - Parameters:
- valueDimensionRecordorDataCoordinate
- Record to remove, or its data ID. 
 
- value
- Raises:
- KeyError
- Raised if there is no matching record. 
 
 
 - union(other: DimensionRecordSet) DimensionRecordSet¶
- Return a new set with all records that are either in - selfor- other.- Parameters:
- otherDimensionRecordSet
- Another record set with the same record type. 
 
- other
- Returns:
- intersectionDimensionRecordSet
- A new record set with all elements in either set. 
 
- intersection
 
 - update(values: Iterable[DimensionRecord], replace: bool = True) None¶
- Add new records to the set. - Parameters:
- valuesIterable[DimensionRecord]
- Records to add. 
- replacebool, optional
- If - True(default) replace any existing records with the same data IDs. If- Falsethe existing records will be kept.
 
- values
- Raises:
- ValueError
- Raised if - value.element != self.element.
 
 
 - update_from_data_coordinates(data_coordinates: Iterable[DataCoordinate]) None¶
- Add records to the set by extracting and deduplicating them from data coordinates. - Parameters:
- data_coordinatesIterable[DataCoordinate]
- Data coordinates to extract from. - DataCoordinate.hasRecordsmust be- True.
 
- data_coordinates