check (class)

@package Classes.check check fonction for classes @date Created on Wed Nov 05 10:10:34 2014 @copyright (C) 2014-2015 EOMYS ENGINEERING. @author pierre_b

set_array(obj, prop, value)[source]

Set an array that can be None or a list

Parameters:
  • obj – Object to set
  • prop (str) – Name of the property to set
  • value – Value to set
Returns:

Return type:

None

check_init_dict(init_dict, key_list)[source]

Check if init_dict is correct to initialize the Object (all the keys of init_dict are in key_list)

Parameters:
  • init_dict (dict) – The dictionary to check
  • key_list (list) – List of the expected key (str)
Returns:

Return type:

None

Raises:
  • NotADictError – init_dict is not a dictionary
  • MissingInitDictKeyError – A key is missing in init_dict
check_var(var_name, value, expect_type, Vmin=None, Vmax=None)[source]

Check if var_name can be set with value

Parameters:
  • var_name (str) – The name of the property to set
  • value – The value to check
  • expected_type (str) – The name of the expected type for value
  • Vmin (float) – Value must be >Vmin (None if the property has no Vmin) (Default value = None)
  • Vmax (float) – Value must be <Vmax (None if the property has no Vmax) (Default value = None)
Returns:

Return type:

None

Raises:

CheckError – The value is incorrect for var_name

check_type(var_name, value, expect_type, type_value)[source]

Check if value has the excpeted type for var_name

Parameters:
  • var_name (str) – The name of the property to set
  • value – The value to check
  • expected_type (str) – The name of the expected type for value (str)
  • type_value – The name of the actual type of the variable
  • expect_type
Raises:

CheckTypeError – Value has a wrong type for var_nam

check_min(var_name, value, type_value, Vmin)[source]

Check if value is greater than the min of var_name

Parameters:
  • var_name (str) – The name of the property to set
  • value – The value to check (int, float or ndarray)
  • type_value (str) – The name of the actual type of the variable
  • Vmin (float) – Value must be >Vmin
Returns:

Return type:

None

Raises:

CheckMinError – value is too small for var_nam

check_max(var_name, value, type_value, Vmax)[source]

Check if value is less than the max of var_name

Parameters:
  • var_name (str) – The name of the property to set
  • value – The value to check (int, float or ndarray)
  • type_value (str) – The name of the actual type of the variable
  • Vmax (float) – Value must be <Vmax
Returns:

Return type:

None

Raises:

CheckMaxError – value is too large for var_nam

exception CheckError[source]

Bases: Exception

exception CheckMinError[source]

Bases: pyleecan.Classes.check.CheckError

exception CheckMaxError[source]

Bases: pyleecan.Classes.check.CheckError

exception CheckTypeError[source]

Bases: pyleecan.Classes.check.CheckError

exception InitUnKnowClassError[source]

Bases: pyleecan.Classes.check.CheckError

exception UnknowInitDictKeyError[source]

Bases: pyleecan.Classes.check.CheckError

exception NotADictError[source]

Bases: pyleecan.Classes.check.CheckError