tools

Module Contents

class text_format[source]
PURPLE = 
CYAN = 
DARKCYAN = 
BLUE = 
GREEN = 
YELLOW = 
WHITE = 
RED = 
BOLD = 
UNDERLINE = 
END = 
software_version()[source]
find_and_replace(begin_char, end_char, theStr, replace_function)[source]
create_unique_dirname(dirname)[source]
applyEquation(objectIn, s)[source]

Apply literal expression based on an object

Parameters:
  • objectIn – Object
  • s – literal expression. Float variables taken from the object are written between {}, int between []. Example: s=”{x}+{y}*2” if x and y are attributes of objectIn.
Returns:

value (float)

arithmeticEval(s)[source]
isNonePrintMessage(theObject, theMessage, show_type=SHOW_INFO)[source]
getPath_workspace()[source]
getLineInfo(lvl=1)[source]
printIfShown(theStr, show_type=SHOW_DEBUG, isToPrint=True, appendTypeName=True)[source]
universalPath(thePath)[source]
add_suffix_to_path(thePath, suffix)[source]
get_object_attrs(obj)[source]
cart2pol(x, y)[source]
pol2cart(rho, phi)[source]
partition(array, begin, end)[source]
quicksort(array)[source]
rsetattr(obj, attr, val)[source]
rgetattr(obj, attr)[source]

Recursively get an attribute from object. Extends getattr method

Parameters:
  • obj – object
  • attr – attribute to get
Returns:

indentParagraph(text_in, indent_level=1)[source]
dist(p, q)[source]

Return the Euclidean distance between points p and q. :param p: [x, y] :param q: [x, y] :return: distance (float)

sparse_subset(points, r)[source]

Returns a maximal list of elements of points such that no pairs of points in the result have distance less than r. :param points: list of tuples (x,y) :param r: distance :return: corresponding subset (list), indices of the subset (list)

integrate(x, y)[source]

Performs Integral(x[0] to x[-1]) of y dx

Parameters:
  • x – x axis coordinates (list)
  • y – y axis coordinates (list)
Returns:

integral value

my_fourier(x, y, n, L)[source]

Fourier analys

Parameters:
  • x – x axis coordinates
  • y – y axis coordinates
  • n – number of considered harmonic
  • L – half-period length
Returns:

a and b coefficients (y = a*cos(x) + b*sin(y))

linspace(start, stop, npoints)[source]
truncate(theStr, truncsize)[source]
str_all_attr(theObject, max_recursion_level)[source]
get_2D_pareto(xList, yList, max_X=True, max_Y=True)[source]
get_ND_pareto(objectives_list, are_maxobjectives_list=None)[source]

Return the N-D pareto front

Parameters:
  • objectives_list – list of list of objectives: example [[0,1], [1,1], [2,2]]
  • are_maxobjectives_list – for each objective, tells if they are to be maximized or not: example [True, False]. Default: False
Returns:

extracted_pareto, indices: list of [x, y, …] points forming the pareto front, and list of the indices of these points from the base list.

derivate(t, y)[source]
class fast_LUT_interpolation(independent_variables, dependent_variables)[source]

Class designed for fast interpolation in look-up table when successive searchs are called often. Otherwise use griddata

interpolate(self, point, fill_value=np.nan)[source]

Perform the interpolation :param point: coordinates to interpolate (tuple or list of tuples for multipoints) :param fill_value: value to put if extrapolated. :return: coordinates

delete_indices_from_list(indices, theList)[source]

Delete elements from list at indices :param indices: list :param theList: list