Core functions¶
The Core package implements general Python functions required by the thermoengine package. Typically, these are focused on interfacing with Objective-C vectors, arrays, matrices, etc.
-
core.
fill_array
(var1, var2)[source]¶ Equilizes the dimension (shape) of two arrays or an array/scalar pair.
This function is not normally called outside the equilibratepy module.
On input
var1
andvar2
are either scalar/array pairs or arrays of the same shape. On output, the function returns a tuple with both arrays of the same shape. A scalar is extended with contant entries if that action is required to match the dimension of a scalar/array pair. Two scalars are converted to two single dimension numpy arrays of length one.Uses the
numpy.full_like
function.- Parameters
- var1scalar or array
If
var1
is an array,var2
must be either a scalar or an array of the same shape.- var2scalar or array
If
var2
is an array,var1
must be either a scalar or an array of the same shape.
- Returns
- resulttuple, (numpy array, numpy array)
var1
andvar2
converted to numpy arrays
Examples
>>> t = [500.0, 600.0] >>> p = 1000.0 >>> t_a, p_a = fill_array(t, p) >>> print (t_a) [500.0, 600.0] >>> print (p_a) [1000.0, 1000.0]
-
core.
double_vector_to_array
(vec)[source]¶ Converts a DoubleVector Objective-C instance into a numpy 1-D array.
This function is not normally called outside the equilibratepy module.
- Parameters
- vecan instance of the Objective-C class DoubleVector
Contents of
vec
are a sequence of double precision entries.
- Returns
- arraynumpy array
Contents of
vec
as a 1-D numpy array
-
core.
array_to_double_vector
(array)[source]¶ Converts a 1-D numpy array into an instance of a DoubleVector Objective-C class.
This function is not normally called outside the equilibratepy module.
- Parameters
- arrayan instance of a 1-D numpy array
Contents of
array
must be a sequence of double precision entries.
- Returns
- vecan instance of the Objective-C class DoubleVector
Contents of
array
as a pointer to an instance of DoubleVector
-
core.
double_matrix_to_array
(mat)[source]¶ Converts a DoubleMatrix Objective-C instance into a numpy 2-D array.
This function is not normally called outside the equilibratepy module.
- Parameters
- matan instance of the Objective-C class DoubleMatrix
Contents of
mat
are a sequence of double precision entries organized as a matrix.
- Returns
- arraynumpy array
Contents of
mat
as a 2-D numpy array
-
core.
get_src_object
(classnm, return_class=False)[source]¶ Initialize object from underlying source code.
- Parameters
- classnm: str
Name of src class
- return_class: bool, default False
If True, return both src object and class as a tuple
- Returns
- src_obj: initialized src object
- src_cls: (if return_class is True) src class