Helper functions for comparing `lsst.pex.config.Config` instancess.
Theses function should be use for any comparison in a `lsst.pex.Config.compare`
or `lsst.pex.config.Field._compare` implementation, as they take care of
writing messages as well as floating-point comparisons and shortcuts.
lsst.pex.config.comparison.compareConfigs |
( |
| name, |
|
|
| c1, |
|
|
| c2, |
|
|
| shortcut = True, |
|
|
| rtol = 1e-8, |
|
|
| atol = 1e-8, |
|
|
| output = None ) |
Compare two `lsst.pex.config.Config` instances for equality.
This function is a helper for `lsst.pex.config.Config.compare`.
Parameters
----------
name : `str`
Name to use when reporting differences, typically created by
`getComparisonName`.
c1 : `lsst.pex.config.Config`
Left-hand side config to compare.
c2 : `lsst.pex.config.Config`
Right-hand side config to compare.
shortcut : `bool`, optional
If `True`, return as soon as an inequality is found. Default is `True`.
rtol : `float`, optional
Relative tolerance for floating point comparisons.
atol : `float`, optional
Absolute tolerance for floating point comparisons.
output : callable, optional
A callable that takes a string, used (possibly repeatedly) to report
inequalities. For example: `print`.
Returns
-------
areEqual : `bool`
`True` when the two `lsst.pex.config.Config` instances are equal.
`False` if there is an inequality.
See Also
--------
lsst.pex.config.compareScalars
Notes
-----
Floating point comparisons are performed by `numpy.allclose`.
If ``c1`` or ``c2`` contain `~lsst.pex.config.RegistryField` or
`~lsst.pex.config.ConfigChoiceField` instances, *unselected*
`~lsst.pex.config.Config` instances will not be compared.
lsst.pex.config.comparison.compareScalars |
( |
| name, |
|
|
| v1, |
|
|
| v2, |
|
|
| output, |
|
|
| rtol = 1e-8, |
|
|
| atol = 1e-8, |
|
|
| dtype = None ) |
Compare two scalar values for equality.
This function is a helper for `lsst.pex.config.Config.compare`.
Parameters
----------
name : `str`
Name to use when reporting differences, typically created by
`getComparisonName`.
v1 : object
Left-hand side value to compare.
v2 : object
Right-hand side value to compare.
output : callable or `None`
A callable that takes a string, used (possibly repeatedly) to report
inequalities (for example, `print`). Set to `None` to disable output.
rtol : `float`, optional
Relative tolerance for floating point comparisons.
atol : `float`, optional
Absolute tolerance for floating point comparisons.
dtype : class, optional
Data type of values for comparison. May be `None` if values are not
floating-point.
Returns
-------
areEqual : `bool`
`True` if the values are equal, `False` if they are not.
See Also
--------
lsst.pex.config.compareConfigs
Notes
-----
Floating point comparisons are performed by `numpy.allclose`.