cfunits.Units.isvalid

Units.isvalid

Whether the units are valid.

See also

reason_notvalid

Examples

>>> u = Units('km')
>>> u.isvalid
True
>>> u.reason_notvalid
''
>>> u = Units('Bad Units')
>>> u.isvalid
False
>>> u.reason_notvalid
"Invalid units: 'Bad Units'; Not recognised by UDUNITS"
>>> u = Units('days since 2000-1-1', calendar='Bad Calendar')
>>> u.isvalid
False
>>> u.reason_notvalid
"Invalid calendar='Bad Calendar'; calendar must be one of ['standard', 'gregorian', 'proleptic_gregorian', 'noleap', 'julian', 'all_leap', '365_day', '366_day', '360_day'], got 'bad calendar'"