ballet.util package¶
-
ballet.util.
dfilter
(call, pred)[source]¶ Decorate a callable with a filter that accepts a predicate
Example:
>>> @dfilter(lambda x: x >= 0) ... def numbers(): ... return [-1, 2, 0, -2] [2, 0]
-
ballet.util.
falsy
(o)[source]¶ Check whether o is falsy
In this case, a falsy value is one of the following: 1. the singleton value False 2. the string ‘false’ (ignoring case) 3. the empty string
- Return type
bool
-
ballet.util.
get_arr_desc
(arr)[source]¶ Get array description, in the form ‘<array type> <array shape>’
- Return type
str
-
ballet.util.
has_nans
(obj)[source]¶ Check if obj has any NaNs
Compatible with different behavior of np.isnan, which sometimes applies over all axes (py35+) and sometimes does not (py34).
- Return type
bool
-
ballet.util.
nonnegative
(call, name=None)[source]¶ Warn if the function’s return value is negative and set it to 0
-
ballet.util.
skipna
(a, b, *c, how='left')[source]¶ Drop rows of both a and b corresponding to missing values
The length of a and b along the first dimension must be equal.
- Parameters
a (
ndarray
) – first arrayb (
ndarray
) – second array*c – any additional arrays
how (
str
) – how to determine the rows to drop, one of ‘left’, ‘any’, or ‘all’. If left, then any row in which a has a missing value is dropped. If any, then any row in which at least one of a, b, or additional arrays has a missing value is dropped. If all , then any row in which all of a, b, and additional arrays has a missing value is dropped. Defaults to left.
- Returns
tuple of a, b, and any additional arrays where a, b, and any additional arrays are guaranteed to be the same length with missing values removed according to
how
.
-
ballet.util.
truthy
(*a, **kw)¶ Check whether o is truthy
In this case, a truthy value is any value that is not falsy.