Module Tools | Source |
---|
module contains a mixed bag of "usefull" methods.
getItem( k ) |
---|
Return the k-th item of the ilist
or the last when not enough
or the ilist itself when it is not a list
Parameters
- ilist : an item or a list of items
List to obtain an item from - k : int
item to be returned
firstIndex( condition=lambda x: True ) |
---|
If the condition is not given, it returns 0
Parameters
- iterable : iterable
to find the first item in - condition : lambda function
the condition
Raises
StopIteration: if no item satysfing the condition is found.
Examples
firstIndex( (1,2,3), condition=lambda x: x % 2 == 0)
2
firstIndex( range( 3, 100 ) )
3
firstIndex( () )
Traceback (most recent call last)
...
StopIteration
getColumnData( kcol ) |
---|
Parameters
xdata 2D array_like or Table
the data array
kcol int
column index
isBetween( x, xe ) |
---|
where the order of xs, xe is unknown.
getKwargs( ) |
---|
setAttribute( name, value, type=None, islist=False, isnone=False ) |
---|
Parameters
- obj : object
to set the attribute to - name : str
of the attribute - value : any
of the attribute - type : class
check class of the object - islist : boolean
check if it is a list of type - isnone : boolean
value could be a None
Raises
TypeError : if any checks fails
setNoneAttributes( name, value, listNone ) |
---|
Parameters
- obj : object
to place the attribute in - name : str
of the attribute - value : any
of the attribute - listNone : list of names
that could have a None value
Returns
True on succesful insertion. False otherwise.
Raises
TypeError if the type is not as in the dictionary
setListOfAttributes( name, value, dictList ) |
---|
""" Set attribute contained in dictionary dictList into the attr-list. A list is a native list or a numpy.ndarray. It also checks the type. if values is a singular item of the proper type it will be inserted as [value].
Parameters
- obj : object
to place the attribute in - name : str
of the attribute - value : any
of the attribute - dictList : dictionary
of possible attributes {"name": type}
Returns
True on succesful insertion. False otherwise.
Raises
TypeError if the type is not as in the dictionary
setSingleAttributes( name, value, dictSingle ) |
---|
Parameters
- obj : object
to place the attribute in - name : str
of the attribute - value : any
of the attribute - dictSingle : dictionary
of possible attributes {"name": type}
Returns
True on succesful insertion. False otherwise.
Raises
TypeError if the type is not as in the dictionary
makeNext( k ) |
---|
""" Return next item of x, and last item if x is exhausted. Or x itself if x is singular.
length( ) |
---|
toArray( ndim=1, dtype=None ) |
---|
Parameters
- x : any number, list/array of numbers or []
to be converted to numpy.ndarray - ndim : int
minimum number of dimensions present - dtype : type
conversion to type (None : as is)
isList( cls ) |
---|
(True,True) if item is a (list|ndarray) of instances of cls
(False,False) if not
isInstance( cls ) |
---|
ndprint( form='{0:.3f}' ) |
---|
decorate( des, copy=True ) |
---|
Parameters
- src : object
source of the attributes - des : object
destiny for the attributes - copy : bool
if True: copy
subclassof( cls ) |
---|
Parameters
- sub : class object
supposed sub class - cls : class object
supposed parent class
printclass( nitems=8, printId=False ) |
---|
printlist( nitems=8 ) |
---|
shortName( ) |
---|
nicenumber( ) |
---|
fix2int( ) |
---|
Parameters
- x : array_like
array of integer floats
track( ) |
---|
Parameters
- statement : str
statement to be traced
average( weights=None, circular=None ) |
---|
Parameters
- xx : array_like
input to be averaged - weights : array_like
if present these are the weights - circular : list of 2 floats
the input is a circular item between [low,high]