MCPcopy Create free account
hub / github.com/NCAR/wrf-python / check_units

Function check_units

src/wrf/units.py:314–334  ·  view source on GitHub ↗

Raise an exception if the unit name is invalid. Args: unit (:obj:`str`): The unit name. unit_type (:obj:`str`): The type of unit. Returns: None Raises: :class:`ValueError`: Raised when the unit name is invalid.

(unit, unit_type)

Source from the content-addressed store, hash-verified

312
313
314def check_units(unit, unit_type):
315 """Raise an exception if the unit name is invalid.
316
317 Args:
318
319 unit (:obj:`str`): The unit name.
320
321 unit_type (:obj:`str`): The type of unit.
322
323 Returns:
324
325 None
326
327 Raises:
328
329 :class:`ValueError`: Raised when the unit name is invalid.
330
331 """
332 u_cleaned = dealias_and_clean_unit(unit)
333 if u_cleaned not in _VALID_UNITS[unit_type]:
334 raise ValueError("invalid unit type '{}'".format(unit))
335
336
337def do_conversion(var, vartype, var_unit, dest_unit):

Callers 1

func_wrapperFunction · 0.85

Calls 1

dealias_and_clean_unitFunction · 0.85

Tested by

no test coverage detected