curepy.utilities.utilities module

curepy.utilities.utilities module#

Utilities functions

curepy.utilities.utilities.flatten_array(A: ndarray) tuple[source]#

Flatten array and return the flattened array and the original shape.

Parameters:

A – Array to be flattened.

Returns:

Tuple of (A_flat, shape).

curepy.utilities.utilities.format_correlation(y: ndarray | list, corr: ndarray | str | None) ndarray | None[source]#

Format a correlation matrix from user-provided inputs.

Parameters:
  • y – Reference variable used to determine the length of the correlation matrix.

  • corr

    Correlation specification. Accepted values:

    • None — no correlation (returns None).

    • "rand" — random (diagonal identity matrix).

    • "syst" — fully systematic (all-ones matrix).

    • Custom square numpy.ndarray.

Returns:

Formatted correlation matrix, or None.

curepy.utilities.utilities.reshape_array(A_flat: ndarray, shape: tuple) ndarray[source]#

Reshape a flattened array to a given shape.

Parameters:
  • A_flat – Flattened array.

  • shape – Target shape.

Returns:

Reshaped array.

curepy.utilities.utilities.to_ragged_array(list_of_lists: list) ndarray[source]#

Convert a list of arrays (possibly of different lengths) to a NumPy object array.

Parameters:

list_of_lists – List whose elements are sub-arrays or None.

Returns:

1-D NumPy object array where each element is a numpy.ndarray or None.