Parameter¶
- class astropy.cosmology.Parameter(fvalidate='default', doc=None, *, unit=None, equivalencies=[], fmt='.3g', derived=False)[source]¶
Bases:
object
Cosmological parameter (descriptor).
Should only be used with a
Cosmology
subclass.- Parameters
- fvalidate
python:callable()
[[object
,object
,Any
],Any
] orpython:str
, optional 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()
.- doc
python:str
orpython:None
, optional Parameter description.
- unitastropy:unit-like or
python:None
(optional, keyword-only) The
Unit
for the Parameter. If None (default) no unit as assumed.- equivalencies
Equivalency
or python:sequence thereof Unit equivalencies for this Parameter.
- fmt
python:str
(optional, keyword-only) format
specification, used when making string representation of the containing Cosmology. See https://docs.python.org/3/library/string.html#formatspec- derivedbool (optional, keyword-only)
Whether the Parameter is ‘derived’, default
False
. Derived parameters behave similarly to normal parameters, but are not sorted by theCosmology
signature (probably not there) and are not included in all methods. For reference, seeOde0
inFlatFLRWMixin
, which removes \(\Omega_{de,0}\) as an independent parameter (\(\Omega_{de,0} \equiv 1 - \Omega_{tot}\)).
- fvalidate
Examples
For worked examples see
FLRW
.Attributes Summary
Whether the Parameter is derived; true parameters are not.
Equivalencies used when initializing Parameter.
String format specification.
Function to validate a potential value of this Parameter..
Parameter name.
Parameter unit.
Methods Summary
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¶
String format specification.
- fvalidate¶
Function to validate a potential value of this Parameter..
- name¶
Parameter name.
- unit¶
Parameter unit.
Methods Documentation
- classmethod register_validator(key, fvalidate=None)[source]¶
Decorator to register a new kind of validator function.
- Parameters
- key
python:str
- fvalidate
python:callable()
[[object
,object
,Any
],Any
] orpython:None
, optional Value validation function.
- key
- Returns
validator
orpython:callable()
[validator
]if validator is None returns a function that takes and registers a validator. This allows
register_validator
to be used as a decorator.