plotypus.utils module¶
-
plotypus.utils.
verbose_print
(message, *, operation, verbosity)[source]¶ Prints message to stderr only if the given operation is in the list verbosity. If “all” is in verbosity, all operations are printed.
Parameters
- message : str
- The message to print.
- operation : str
- The type of operation being performed.
- verbosity : [str] or None
- The list of operations to print message for. If “all” is contained in the list, then all operations are printed. If None, no operation is printed.
Returns
None
-
plotypus.utils.
pmap
(func, args, processes=None, callback=do_nothing, **kwargs)[source]¶ Parallel equivalent of
map(func, args)
, with the additional ability of providing keyword arguments to func, and a callback function which is applied to each element in the returned list. Unlike map, the output is a non-lazy list. If processes is 1, no thread pool is used.Parameters
- func : function
- The function to map.
- args : iterable
- The arguments to map func over.
- processes : int or None, optional
- The number of processes in the thread pool. If only 1, no thread pool
is used to avoid useless overhead. If None, the number is chosen based
on your system by
multiprocessing.Pool
(default None). - callback : function, optional
- Function to call on the return value of
func(arg)
for each arg in args (default do_nothing). - kwargs : dict
- Extra keyword arguments are unpacked in each call of func.
Returns
- results : list
- A list equivalent to
[func(x, **kwargs) for x in args]
.
-
plotypus.utils.
make_sure_path_exists
(path)[source]¶ Creates the supplied path if it does not exist. Raises OSError if the path cannot be created.
Parameters
- path : str
- Path to create.
Returns
None
-
plotypus.utils.
get_signal
(data)[source]¶ Returns all of the values in data that are not outliers.
Parameters
data : masked array
Returns
- signal : array
- Non-masked values in data.
-
plotypus.utils.
get_noise
(data)[source]¶ Returns all identified outliers in data.
Parameters
data : masked array
Returns
- noise : array
- Masked values in data.
-
plotypus.utils.
colvec
(X)[source]¶ Converts a row-vector X into a column-vector.
Parameters
X : array-like, shape = [n_samples]
Returns
out : array-like, shape = [n_samples, 1]
-
plotypus.utils.
mad
(data, axis=None)[source]¶ Computes the median absolute deviation of data along a given axis. See link for details.
Parameters
data : array-like
Returns
mad : number or array-like
-
plotypus.utils.
autocorrelation
(X, lag=1)[source]¶ Computes the autocorrelation of X with the given lag. Autocorrelation is simply autocovariance(X) / covariance(X-mean, X-mean), where autocovariance is simply covariance((X-mean)[:-lag], (X-mean)[lag:]).
See link for details.
Parameters
X : array-like, shape = [n_samples]
- lag : int, optional
- Index difference between points being compared (default 1).