MetricsDelegate¶
- class lsst.daf.butler.tests.MetricsDelegate(storageClass: StorageClass)¶
Bases:
StorageClassDelegate
Parameter handler for parameters using Metrics.
Methods Summary
assemble
(components[, pytype])Construct an object from components based on storageClass.
copy
(inMemoryDataset)Copy the supplied python type and return the copy.
disassemble
(composite[, subset, override])Disassembler a composite.
getComponent
(composite, componentName)Attempt to retrieve component from composite object by heuristic.
handleParameters
(inMemoryDataset[, parameters])Modify the in-memory dataset using the supplied parameters, returning a possibly new object.
selectResponsibleComponent
(readComponent, ...)Select the best component for calculating a derived component.
Methods Documentation
- assemble(components: dict[str, Any], pytype: type | None = None) Any ¶
Construct an object from components based on storageClass.
This generic implementation assumes that instances of objects can be created either by passing all the components to a constructor or by calling setter methods with the name.
- Parameters:
- Returns:
- composite
object
New composite object assembled from components.
- composite
- Raises:
- ValueError
Some components could not be used to create the object or, alternatively, some components were not defined in the associated StorageClass.
- copy(inMemoryDataset: Any) Any ¶
Copy the supplied python type and return the copy.
- Parameters:
- inMemoryDataset
object
Object to copy.
- inMemoryDataset
- Returns:
- copied
object
A copy of the supplied object. Can be the same object if the object is known to be read-only.
- copied
- Raises:
- NotImplementedError
Raised if none of the default methods for copying work.
Notes
The default implementation uses
copy.deepcopy()
. It is generally expected that this method is the equivalent of a deep copy. Subclasses can override this method if they already know the optimal approach for deep copying.
- disassemble(composite: Any, subset: Iterable | None = None, override: Any | None = None) dict[str, lsst.daf.butler.core.storageClassDelegate.DatasetComponent] ¶
Disassembler a composite.
This is a generic implementation of a disassembler. This implementation attempts to extract components from the parent by looking for attributes of the same name or getter methods derived from the component name.
- Parameters:
- composite
object
Parent composite object consisting of components to be extracted.
- subsetiterable, optional
Iterable containing subset of components to extract from composite. Must be a subset of those defined in
StorageClassDelegate.storageClass
.- override
object
, optional Object to use for disassembly instead of parent. This can be useful when called from subclasses that have composites in a hierarchy.
- composite
- Returns:
- Raises:
- ValueError
A requested component can not be found in the parent using generic lookups.
- TypeError
The parent object does not match the supplied
StorageClassDelegate.storageClass
.
- getComponent(composite: Any, componentName: str) Any ¶
Attempt to retrieve component from composite object by heuristic.
Will attempt a direct attribute retrieval, or else getter methods of the form “get_componentName” and “getComponentName”.
- handleParameters(inMemoryDataset: Any, parameters: Mapping[str, Any] | None = None) Any ¶
Modify the in-memory dataset using the supplied parameters, returning a possibly new object.
- Parameters:
- Returns:
- inMemoryDataset
object
Updated form of supplied in-memory dataset, after parameters have been used.
- inMemoryDataset
- classmethod selectResponsibleComponent(readComponent: str, fromComponents: set[str | None]) str ¶
Select the best component for calculating a derived component.
Given a possible set of components to choose from, return the component that should be used to calculate the requested derived component.
- Parameters:
- Returns:
- required
str
The component that should be used.
- required
- Raises:
- NotImplementedError
Raised if this delegate refuses to answer the question.
- ValueError
Raised if this delegate can not determine a relevant component from the supplied options.