splicedArray
Examples:
'''python
vanilla_numpy_array = np.array([np.nan,1,2,3,3,np.nan,np.nan,23,32,np.nan,2212,2,2,332])
better_array = splicedArray(test)
print(better_array) #this is still a numpy array... but boosted with special abilities :
print(better_array.a) #use array.a to get only non_nan values off the array. Usefull to feed into functions that do not cope well with nans.
To get back the nan at the places of the original array into itself, or an array of the same shape where values have been transformed by any function, use either
transformed_better_array = better_array( a_function_not_working_with_nans( better_array.a ) )
print(toast(toast.a)) #equivalent of doing that.
'''
Tip
When using the call better_array(array)
to put back nan in place,
if the shape has changed on one dimension, for example,
because of a numerical derivative operation, the output array will be
given back it's original shape, appendded at the end by as much np.nan as
necessary.
This can be adjusted by adding a second optionnal parameter, with value,
"start"
,"end"
,or "none"
. Default is "end"
Example :
better_array(array,"none") #will not be shape-fixed
better_array(array,"start") #will not shape-fixed by addind np.nan at the start IF NECESSARY.
Attributes
signals.splicedArray.a
property
readonly
Extracts only the non_nan values off the array.
Returns:
Type | Description |
---|---|
np.array |
An array with no nan inside. |