optimus.utils.conversions
Utilities for data type checks and conversions.
Module Contents
Functions
|
Check if the input value can be converted into a positive integer. |
|
Check if the input value can be converted into a float. |
|
Check if the input value can be converted into a positive float. |
|
Check if the input vector can be converted into an array for the specified |
|
Check if the input vector can be converted into an array for the specified |
|
Convert the input array into a 3xN Numpy array, if possible. |
- optimus.utils.conversions.convert_to_positive_int(value, label='variable')
Check if the input value can be converted into a positive integer.
- Parameters
- valueAny
The input value to be converted into a positive integer.
- labelstr
The name of the variable.
- Returns
- valueint
The output value.
- optimus.utils.conversions.convert_to_float(value, label='variable')
Check if the input value can be converted into a float.
- Parameters
- valueAny
The input value to be converted into a float.
- labelstr
The name of the variable.
- Returns
- valuefloat
The output value.
- optimus.utils.conversions.convert_to_positive_float(value, label='variable', nonnegative=False)
Check if the input value can be converted into a positive float.
- Parameters
- valueAny
The input value to be converted into a positive float.
- labelstr
The name of the variable.
- nonnegativebool
Check for nonnegative instead of strictly positive numbers.
- Returns
- valuefloat
The output value.
- optimus.utils.conversions.convert_to_array(vector, shape=None, label='variable')
Check if the input vector can be converted into an array for the specified shape, and perform the conversion.
- Parameters
- vectorAny
The input vector to be converted into a Numpy array.
- shapetuple[int], None
The output shape of the vector.
- labelstr
The name of the variable.
- Returns
- arraynumpy.ndarray
The output array with the specified shape.
- optimus.utils.conversions.convert_to_complex_array(vector, shape=None, label='variable')
Check if the input vector can be converted into an array for the specified shape, and perform the conversion.
- Parameters
- vectorAny
The input vector to be converted into a Numpy array.
- shapetuple[int], None
The output shape of the vector.
- labelstr
The name of the variable.
- Returns
- arraynumpy.ndarray[complex]
The output array with the specified shape.
- optimus.utils.conversions.convert_to_3n_array(array, label='variable')
Convert the input array into a 3xN Numpy array, if possible.
- Parameters
- arrayAny
The input vector to be converted into a 3xN Numpy array.
- labelstr
The name of the variable.
- Returns
- arraynumpy.ndarray
The output array with the shape (3,N).