Parameter¶
- class astropy.cosmology.Parameter(*, derived=False, unit=None, equivalencies=[], fvalidate='default', fmt='', doc=None)[source]¶
Bases:
objectCosmological parameter (descriptor).
Should only be used with a
Cosmologysubclass.- Parameters:
- derivedbool (optional, keyword-only)
Whether the Parameter is ‘derived’, default
False. Derived parameters behave similarly to normal parameters, but are not sorted by theCosmologysignature (probably not there) and are not included in all methods. For reference, seeOde0inFlatFLRWMixin, which removes \(\Omega_{de,0}`\) as an independent parameter (\(\Omega_{de,0} \equiv 1 - \Omega_{tot}\)).- unitastropy:unit-like or
None(optional, keyword-only) The
Unitfor the Parameter. If None (default) no unit as assumed.- equivalencies
Equivalencyor sequence thereof Unit equivalencies for this Parameter.
- fvalidate
callable()[[object,object,Any],Any] orstr(optional, keyword-only) Function to validate the Parameter value from instances of the cosmology class. If “default”, uses default validator to assign units (with equivalencies), if Parameter has units. For other valid string options, see
Parameter._registry_validators. ‘fvalidate’ can also be set through a decorator withvalidator().- fmt
str(optional, keyword-only) formatspecification, used when making string representation of the containing Cosmology. See https://docs.python.org/3/library/string.html#formatspecDeprecated since version 5.1.
- doc
strorNone(optional, keyword-only) Parameter description.
Examples
For worked examples see
FLRW.Attributes Summary
Whether the Parameter is derived; true parameters are not.
Equivalencies used when initializing Parameter.
Deprecated since version 5.1.
Function to validate a potential value of this Parameter.
Parameter name.
Parameter unit.
Methods Summary
clone(**kw)Clone this
Parameter, changing any constructor argument.register_validator(key[, fvalidate])Decorator to register a new kind of validator function.
validate(cosmology, value)Run the validator on this Parameter.
validator(fvalidate)Make new Parameter with custom
fvalidate.Attributes Documentation
- derived¶
Whether the Parameter is derived; true parameters are not.
- equivalencies¶
Equivalencies used when initializing Parameter.
- format_spec¶
Deprecated since version 5.1: The format_spec attribute is deprecated and may be removed in a future version.
- fvalidate¶
Function to validate a potential value of this Parameter.
- name¶
Parameter name.
- unit¶
Parameter unit.
Methods Documentation
- clone(**kw)[source]¶
Clone this
Parameter, changing any constructor argument.- Parameters:
- **kw
Passed to constructor. The current values, eg.
fvalidateare used as the default values, so an empty**kwis an exact copy.
Examples
>>> p = Parameter() >>> p Parameter(derived=False, unit=None, equivalencies=[], fvalidate='default', doc=None)
>>> p.clone(unit="km") Parameter(derived=False, unit=Unit("km"), equivalencies=[], fvalidate='default', doc=None)
- classmethod register_validator(key, fvalidate=None)[source]¶
Decorator to register a new kind of validator function.
- Parameters:
- Returns:
validatororcallable()[validator]if validator is None returns a function that takes and registers a validator. This allows
register_validatorto be used as a decorator.