Tools

 
 
BayesicFitting.source.Tools (version 3.1.0)
index
/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/BayesicFitting/source/Tools.py

 
Modules
       
inspect
math
numbers
numpy
re
sys
trace

 
Functions
       
average(xx, weights=None, circular=None)
Return (weighted) average and standard deviation of input array.
 
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]
decorate(src, des, copy=True)
Transfer attributes from src to des.
If copy is True try to copy the attributes, otherwise link it.
 
Parameters
----------
src : object
    source of the attributes
des : object
    destiny for the attributes
copy : bool
    if True: copy
fix2int(x)
Return integer array with values as in x
Parameters
----------
x : array_like
    array of integer floats
getColumnData(xdata, kcol)
Return the kcol-th column from xdata
 
Parameters
----------
xdata   2D array_like or Table
    the data array
kcol    int
    column index
getItem(ilist, 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
isBetween(xs, x, xe)
Return True when x falls between xs and xe or on xs or xe.
    where the order of xs, xe is unknown.
isInstance(item, cls)
Returns true when one of the following is true
1. when cls is int   : item is an int or item is a numpy.integer.
2. when cls is float : item is an float or item is an int.
3. when cls is cls   : item is a cls.
isList(item, cls)
Return (True,False) if item is a instance of cls
       (True,True)  if item is a (list|ndarray) of instances of cls
       (False,False) if not
length(x)
Return the length of any item. Singletons have length 1; None has length 0..
makeNext(x, k)
Return next item of x, and last item if x is exhausted.
Or x itself if x is singular.
ndprint(x, form='{0:.3f}')
Print a ndarray, formatted.
nicenumber(x)
Return a nice number close to (but below) |x|.
printclass(cls, nitems=8)
Print the attributes of a class.
printlist(val, nitems=8)
setAttribute(obj, name, value, type=None, islist=False, isnone=False)
setListOfAttributes(obj, 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
setNoneAttributes(obj, name, value, listNone)
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
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
setSingleAttributes(obj, name, value, dictSingle)
Set a singular attribute contained in dictionary dictSingle into the attr-list.
It also checks the type.
 
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
shortName(val)
Return a short version the string representation: upto first non-letter.
toArray(x, ndim=1, dtype=None)
Return a array of x when x is a number
 
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)
track(statement)
Parameters
----------
statement : str
    statement to be traced

 
Data
        __license__ = 'GPL3'
__status__ = 'Perpetual Beta'
__url__ = 'https://www.bayesicfitting.nl'
__year__ = 2023
print_function = _Feature((2, 6, 0, 'alpha', 2),
         (3, 0, 0, 'alpha', 0),
         1048576)


 
Author
        Do Kester