Skip to content

types

tergite_autocalibration.utils.misc.types

Functions:

Name Description
is_bool

Checks whether a given string could be parsed to bool

is_none_str

Check whether a given string is None.

safe_str_to_bool_int_float

Converts a string to the given type

str_to_bool

Casts a string to bool, can be either upper or lower case

is_bool

is_bool(s: str) -> bool

Checks whether a given string could be parsed to bool

Parameters:

Name Type Description Default
s str

String to be parsed

required

Returns:

is_none_str

is_none_str(str_: str) -> bool

Check whether a given string is None.

Parameters:

Name Type Description Default
str_ str

String to check

required

Returns:

Type Description
bool

True if the string is "None" or "none".

safe_str_to_bool_int_float

safe_str_to_bool_int_float(expected_type: Union[bool, int, float, str, Type[bool], Type[int], Type[float], Type[str]], value: str) -> Union[bool, int, float, str]

Converts a string to the given type

Parameters:

Name Type Description Default
expected_type Union[bool, int, float, str, Type[bool], Type[int], Type[float], Type[str]]

The type T to cast the value to, can be bool, float, int or str

required
value str

The value to be cast

required

Returns:

str_to_bool

str_to_bool(s: str) -> bool

Casts a string to bool, can be either upper or lower case

Parameters:

Name Type Description Default
s str

String to cast

required

Returns: