Name¶
-
class
lsst.verify.Name(package=None, metric=None, spec=None)¶ Bases:
objectSemantic name of a package,
MetricorSpecificationin thelsst.verifyframework.Nameinstances are immutable and can be used as keys in mappings.Parameters: - package :
strorName Name of the package, either as a string (
'validate_drp', for example) or as aNameobject (Name(package='validate_drp')for example).The
packagefield can also be fully specified:>>> Name(package='validate_drp.PA1.design_gri') Name('validate_drp', 'PA1', 'design_gri')
Or the
packagefield can be used as the sole positional argument:>>> Name('validate_drp.PA1.design_gri') Name('validate_drp', 'PA1', 'design_gri')
- metric :
strorName Name of the metric. The name can be relative (
'PA') or fully-specified ('validate_drp.PA1').- spec :
strorName Name of the specification. The name can be bare (
'design_gri'), metric-relative ('PA1.design_gri') or fully-specified ('validate_drp.PA1.design_gri')
Raises: - TypeError
Raised when arguments cannot be parsed or conflict (for example, if two different package names are specified through two different fields).
Notes
Names in the Verification Framework are formatted as:
package.metric.specification
A fully-qualified name is one that has all components included. For example, a fully specified metric name is:
validate_drp.PA1
This means: “the
PA1metric in thevalidate_drppackage.An example of a fully-specificed specification name:
validate_drp.PA1.design
This means: “the
designspecification of thePA1metric in thevalidate_drppackage.A relative name is one that’s missing a component. For example:
PA1.design
Asserting this is a relative specification name, the package is not known.
Examples
Creation
There are many patterns for creating Name instances. Different patterns are useful in different circumstances.
You can create a metric name from its components:
>>> Name(package='validate_drp', metric='PA1') Name('validate_drp', 'PA1')
Or a specification name from components:
>>> Name(package='validate_drp', metric='PA1', spec='design') Name('validate_drp', 'PA1', 'design')
You can equivalently create
Names from fully-qualified strings:>>> Name('validate_drp.PA1') Name('validate_drp', 'PA1')
>>> Name('validate_drp.PA1.design') Name('validate_drp', 'PA1', 'design')
You can also use an existing name to specify some components of the name:
>>> metric_name = Name('validate_drp.PA1') >>> Name(metric=metric_name, spec='design') Name('validate_drp', 'PA1', 'design')
A
TypeErroris raised if any components of the input names conflict.Fully-specified metric names can be mixed with a
speccomponent:>>> Name(metric='validate_drp.PA1', spec='design') Name('validate_drp', 'PA1', 'design')
String representation
Converting a
Nameinto astrgives you the canonical string representation, as fully-specified as possible:>>> str(Name('validate_drp', 'PA1', 'design')) 'validate_drp.PA1.design'
Alternatively, obtain the fully-qualified metric name from the
Name.fqnproperty:>>> name = Name('validate_drp', 'PA1', 'design') >>> name.fqn 'validate_drp.PA1.design'
The relative name of a specification omits the package component:
>>> name = Name('validate_drp.PA1.design') >>> name.relative_name 'PA1.design'
Attributes Summary
fqnThe fully-qualified name ( str).has_metricTrueif this object contains a metric name, either relative or fully-qualified (bool).has_packageTrueif this object contains a package name (bool).has_relativeTrueif a relative specification name can be formed from this object, i.e.,metricandspecattributes are set (bool).has_specTrueif this object contains a specification name, either relative or fully-qualified (bool).is_fqTrueif this object is a fully-qualified name of either a package, metric or specification (bool).is_metricTrueif this object is a metric name, either relative or fully-qualified (bool).is_packageTrueif this object is a package name (bool).is_relativeTrueif this object is a specification name that’s not fully-qualified, but is relative to a metric name (bool).is_specTrueif this object is a specification name, either relative or fully-qualified (bool).metricMetric name ( str).packagePackage name ( str).relative_nameThe relative specification name ( str).specSpecification name ( str).Attributes Documentation
-
fqn¶ The fully-qualified name (
str).Raises: - AttributeError
If the name is not a fully-qualified name (check
is_fq)
Examples
>>> Name('validate_drp', 'PA1').fqn 'validate_drp.PA1' >>> Name('validate_drp', 'PA1', 'design').fqn 'validate_drp.PA1.design'
-
has_metric¶ Trueif this object contains a metric name, either relative or fully-qualified (bool).>>> Name('validate_drp.PA1').has_metric True >>> Name(spec='design').has_metric False
-
has_package¶ Trueif this object contains a package name (bool).>>> Name('validate_drp.PA1').has_package True >>> Name(spec='design').has_package False
-
has_relative¶ Trueif a relative specification name can be formed from this object, i.e.,metricandspecattributes are set (bool).
-
has_spec¶ Trueif this object contains a specification name, either relative or fully-qualified (bool).>>> Name(spec='design').has_spec True >>> Name('validate_drp.PA1').has_spec False
-
is_fq¶ Trueif this object is a fully-qualified name of either a package, metric or specification (bool).Examples
A fully-qualified package name:
>>> Name('validate_drp').is_fq True
A fully-qualified metric name:
>>> Name('validate_drp.PA1').is_fq True
A fully-qualified specification name:
>>> Name('validate_drp.PA1.design_gri').is_fq True
-
is_metric¶ Trueif this object is a metric name, either relative or fully-qualified (bool).>>> Name('validate_drp.PA1').is_metric True >>> Name('validate_drp.PA1.design').is_metric False
-
is_package¶ Trueif this object is a package name (bool).>>> Name('validate_drp').is_package True >>> Name('validate_drp.PA1').is_package False
-
is_relative¶ Trueif this object is a specification name that’s not fully-qualified, but is relative to a metric name (bool). relative to a base name. (bool).Package and metric names are never relative.
A relative specification name:
>>> Name(spec='PA1.design_gri').is_relative True
But not:
>>> Name('validate_drp.PA1.design_gri').is_relative False
-
is_spec¶ Trueif this object is a specification name, either relative or fully-qualified (bool).>>> Name('validate_drp.PA1').is_spec False >>> Name('validate_drp.PA1.design').is_spec True
-
package¶ Package name (
str).>>> name = Name('validate_drp.PA1.design') >>> name.package 'validate_drp'
- package :