MetricsDelegate¶
-
class
lsst.daf.butler.tests.
MetricsDelegate
(storageClass: StorageClass)¶ Bases:
lsst.daf.butler.StorageClassDelegate
Parameter handler for parameters using Metrics
Methods Summary
assemble
(components, Any], pytype)Construct an object from components based on storageClass. disassemble
(composite, subset, override)Generic implementation of a disassembler. getComponent
(composite, componentName)Attempt to retrieve component from composite object by heuristic. getValidComponents
(composite)Extract all non-None components from a composite. handleParameters
(inMemoryDataset[, parameters])Modify the in-memory dataset using the supplied parameters, returning a possibly new object. selectResponsibleComponent
(readComponent, …)Given a possible set of components to choose from, return the component that should be used to calculate the requested derived component. Methods Documentation
-
assemble
(components: Dict[str, Any], pytype: Optional[Type[CT_co]] = 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.
Raises: - ValueError
Some components could not be used to create the object or, alternatively, some components were not defined in the associated StorageClass.
- composite :
-
disassemble
(composite: Any, subset: Optional[Iterable[T_co]] = None, override: Optional[bool] = None) → Dict[str, Any]¶ 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.
- subset : iterable, 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.
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
.
- composite :
-
getComponent
(composite, componentName: str)¶ 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”.
Parameters: Returns: - component :
object
Component extracted from composite.
Raises: - AttributeError
The attribute could not be read from the composite.
- component :
-
getValidComponents
(composite: Any) → Dict[str, Any]¶ Extract all non-None components from a composite.
Parameters: - composite :
object
Composite from which to extract components.
Returns: - comps :
dict
Non-None components extracted from the composite, indexed by the component name as derived from the
StorageClassDelegate.storageClass
.
- composite :
-
handleParameters
(inMemoryDataset, parameters=None)¶ 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) → str¶ 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.
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.
- required :
-