exosim.utils.checks#

Functions#

check_units(input_data, desired_units[, ...])

It checks the units of the inputs and returns the quantity rescaled to the desired units.

find_key(input_class_keys, key_list[, calling_class])

Finds which key from key_list is contained in input_class_keys, ignoring case.

look_for_key(input_dict, key, value[, foo])

Returns True if a certain key is in the dictionary and has a certain value.

Module Contents#

check_units(input_data, desired_units, calling_class=None, force=False)[source]#

It checks the units of the inputs and returns the quantity rescaled to the desired units.

Parameters:
  • input_data (ndarray or Quantity) – input class to rescale.

  • desired_units (Quantity) – desired unit for the input qquantity.

  • calling_class (Logger (optional)) – calling class. This is needed to print the eventual debug message inside the calling class.

  • force (bool (optional)) – if True, if the input data has no units, it assumes is expressed in the desired units. Default is False.

Returns:

scaled input quantity.

Return type:

Quantity

Raises:

UnitConversionError – if it cannot convert the original units into the desired ones

find_key(input_class_keys, key_list, calling_class=None)[source]#

Finds which key from key_list is contained in input_class_keys, ignoring case.

Parameters:
  • input_class_keys (list) – List of the input class keys.

  • key_list (list) – List of the desired keys.

  • calling_class (Logger, optional) – Calling class. This is needed to print the eventual debug message inside the calling class.

Returns:

Found key.

Return type:

str

Raises:

KeyError – If no matching key is found.

look_for_key(input_dict, key, value, foo=False)[source]#

Returns True if a certain key is in the dictionary and has a certain value.

Parameters:
  • input_dict (dict) – input dictionary

  • key (str) – key to search

  • value – key content to check

Return type:

bool