lightlab.util.data.basic module¶
Argument sanitizing and very basic array operations
Summary¶
Functions:
argFlatten |
Takes a combination of multiple arguments and flattens the ones of type typs. |
mangle |
Sanitizes attribute names that might be “hidden,” denoted by leading ‘__’. |
minmax |
Returns a list of [min and max] of the array |
rms |
|
verifyListOfType |
Checks to see if the argument is a list or a single object of the checkType Returns a list, even if it is length one If arg is None, it returns None |
Data:
MANGLE_LEN |
int(x=0) -> integer int(x, base=10) -> integer |
Reference¶
-
verifyListOfType(arg, checkType)[source]¶ Checks to see if the argument is a list or a single object of the checkType Returns a list, even if it is length one If arg is None, it returns None
-
argFlatten(*argLists, typs=(<class 'list'>, <class 'tuple'>, <class 'set'>))[source]¶ Takes a combination of multiple arguments and flattens the ones of type typs. None arguments are ignored, no error.
Parameters: - *argLists – multiple arguments that could be lists or tuples
- typs (tuple) – types of things to flatten
Returns: (tuple)
It goes like this:
dUtil.argFlatten() # == () dUtil.argFlatten(1) # == (1,) dUtil.argFlatten((3, 4)) # == (3, 4) dUtil.argFlatten(1, (3, 4), np.zeros(2)) # == (1, 3, 4, ndarray([0,0])) dUtil.argFlatten(1, [3, 4], np.zeros(2)) # == (1, 3, 4, ndarray([0,0])) dUtil.argFlatten(1, [3, 4], np.zeros(2), typs=tuple) # == (1, [3, 4], ndarray([0,0])) dUtil.argFlatten(1, [3, 4], np.zeros(2), typs=np.ndarray) # == (1, [3, 4], 0., 0.)
-
mangle(name, klass)[source]¶ Sanitizes attribute names that might be “hidden,” denoted by leading ‘__’. In
Hashableobjects, attributes with this kind of name can only be class attributes.See
test_instrument_overloadingfor user-side implications.Behavior:
mangle('a', 'B') == 'a' mangle('_a', 'B') == '_a' mangle('__a__', 'B') == '__a__' mangle('__a', 'B') == '_B__a' mangle('__a', '_B') == '_B__a'