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)
| 312 | |
| 313 | |
| 314 | def 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 | |
| 337 | def do_conversion(var, vartype, var_unit, dest_unit): |
no test coverage detected