Utils¶
-
get_func_name
(fun)¶ Returns the name of a function passed as parameter being either a function itself or a string with the function name:
from cvnn.utils import get_func_name get_func_name(print) # output: 'print' get_func_name('print') # output: 'print'
Parameters: fun – function or function name Returns: function name
-
create_folder
(root_path, now=None)¶ Creates folders within
root_path
using a date format.Parameters: - root_path – root path where to create the folder chain
- now – date to be used. If
None
then it will use current time
Returns: the created path in pathlib format (compatible across different OS)
-
transform_to_real
(x_complex, mode="real_imag")¶ - Transforms a complex input matrix into a real value matrix (double size)
Parameters: - x_complex – Complex-valued matrix of size mxn
- mode –
Mode on how to transform to real. One of the following.
real_imag
(default): Separate x_complex into real and imaginary making the size of the return doublex_complex
amplitude_phase
: Separatex_complex
into amplitude and phase making the size of the return doublex_complex
amplitude_only
: Apply the absolute value tox_complex
. Shape remains the same.
Returns: real-valued matrix of real valued cast of
x_complex
-
randomize(x, y):
Randomizes the order of data samples and their corresponding labels
Parameters: - x – data
- y – data labels
Returns: Tuple of (shuffled_x, shuffled_y) maintaining coherence of elements labels
-
polar2cart(rho, angle):
- \[z = \rho \cdot e^{j\phi}\]
Parameters: - rho – absolute value
- angle – phase
Returns: complex number using phase and angle
-
cart2polar(z):
Parameters: z – complex input Returns: tuple with the absolute value of the input and the phase