core

Package Contents

getPath_workspace()[source]
obj_to_json(theObj)[source]

Extract the json dictionary from the object. The data saved are automatically detected, using typehints. ex: x: int=5 will be saved, x=5 won’t.

json_to_obj(json_dict)[source]

Convenience class to create object from dictionary. Only works if CLASS_TAG is valid :param json_dict: dictionary loaded from a json file. :raise TypeError: if class can not be found :raise KeyError: if CLASS_TAG not present in dictionary

json_to_obj_safe(json_dict, cls)[source]

Safe class to create object from dictionary. :param json_dict: dictionary loaded from a json file :param cls: class object to instantiate with dictionary

encode_str_json(theStr)[source]
decode_str_json(theStr)[source]
indentParagraph(text_in, indent_level=1)[source]
rgetattr(obj, attr)[source]

Recursively get an attribute from object. Extends getattr method

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

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)

printIfShown(theStr, show_type=SHOW_DEBUG, isToPrint=True, appendTypeName=True)[source]
SHOW_WARNING = 0
class DataStruct_Interface[source]
get_info(self)[source]

Get simple string describing the datastructure

set_info(self, info)[source]

Set simple string describing the datastructure

__str__(self)[source]
class AutosaveStruct(dataStruct, filename='', change_filename_if_exists=True)[source]

Structure that provides automated save of DataStructures

__str__(self)[source]
get_filename(self)[source]

Get set filename

set_filename(self, filename, change_filename_if_exists)[source]
Parameters:
  • filename – Filename to set
  • change_filename_if_exists – If already exists, create a new filename
stop_autosave(self)[source]

Stop autosave

start_autosave(self, timer_autosave)[source]

Start autosave

save(self, safe_save=True)[source]

Save

get_datastruct(self)[source]

Return :class:’~DataStruct_Interface’

class ListDataStruct[source]

Bases: optimeed.core.collection.DataStruct_Interface

_INFO_STR = info
_DATA_STR = data
save(self, filename)[source]

Save data using json format. The data to be saved are automatically detected, see obj_to_json()

add_data(self, data_in)[source]

Add a data to the list

get_data(self)[source]

Get full list of datas

set_data(self, theData)[source]

Set full list of datas

set_data_at_index(self, data_in, index)[source]

Replace data at specific index

set_attribute_data(self, the_attribute, the_value)[source]

Set attribute to all data

set_attribute_equation(self, attribute_name, equation_str)[source]

Advanced method to set the value of attribute_name from equation_str

Parameters:
  • attribute_name – string (name of the attribute to set)
  • equation_str – formatted equation, check applyEquation()
Returns:

get_list_attributes(self, attributeName)[source]

Get the value of attributeName of all the data in the Collection

Parameters:attributeName – string (name of the attribute to get)
Returns:list
delete_points_at_indices(self, indices)[source]

Delete several elements from the Collection

Parameters:indices – list of indices to delete
export_xls(self, excelFilename, excelsheet='Sheet1', mode='w')[source]

Export the collection to excel. It only exports the direct attributes.

Parameters:
  • excelFilename – filename of the excel
  • excelsheet – name of the sheet
  • mode – ‘w’ to erase existing file, ‘a’ to append sheetname to existing file
merge(self, collection)[source]

Merge a collection with the current collection

Parameters:collectionCollection to merge
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

SHOW_WARNING = 0
SHOW_INFO = 1
SHOW_ERROR = 2
SHOW_DEBUG = 3
SHOW_CURRENT
printIfShown(theStr, show_type=SHOW_DEBUG, isToPrint=True, appendTypeName=True)[source]
SHOW_WARNING = 0
class Data(x: list, y: list, x_label='', y_label='', legend='', is_scattered=False, transfo_x=lambda selfData, x: x, transfo_y=lambda selfData, y: y, xlim=None, ylim=None, permutations=None, sort_output=False, color=None, symbol='o', symbolsize=8, fillsymbol=True, outlinesymbol=1.8, linestyle='-', width=2)[source]

This class is used to store informations necessary to plot a 2D graph. It has to be combined with a gui to be useful (ex. pyqtgraph)

set_data(self, x: list, y: list)[source]

Overwrites current datapoints with new set

get_x(self)[source]

Get x coordinates of datapoints

get_symbolsize(self)[source]

Get size of the symbols

symbol_isfilled(self)[source]

Check if symbols has to be filled or not

get_symbolOutline(self)[source]

Get color factor of outline of symbols

get_length_data(self)[source]

Get number of points

get_xlim(self)[source]

Get x limits of viewbox

get_ylim(self)[source]

Get y limits of viewbox

get_y(self)[source]

Get y coordinates of datapoints

get_color(self)[source]

Get color of the line

get_width(self)[source]

Get width of the line

get_number_of_points(self)[source]

Get number of points

get_plot_data(self)[source]

Call this method to get the x and y coordinates of the points that have to be displayed. => After transformation, and after permutations.

Returns:x (list), y (list)
get_permutations(self)[source]

Return the transformation ‘permutation’: xplot[i] = xdata[permutation[i]]

get_invert_permutations(self)[source]

Return the inverse of permutations: xdata[i] = xplot[revert[i]]

get_dataIndex_from_graphIndex(self, index_graph_point)[source]

From an index given in graph, recovers the index of the data.

Parameters:index_graph_point – Index in the graph
Returns:index of the data
get_dataIndices_from_graphIndices(self, index_graph_point_list)[source]

Same as get_dataIndex_from_graphIndex but with a list in entry. Can (?) improve performances for huge dataset.

Parameters:index_graph_point_list – List of Index in the graph
Returns:List of index of the data
get_graphIndex_from_dataIndex(self, index_data)[source]

From an index given in the data, recovers the index of the graph.

Parameters:index_data – Index in the data
Returns:index of the graph
get_graphIndices_from_dataIndices(self, index_data_list)[source]

Same as get_graphIndex_from_dataIndex but with a list in entry. Can (?) improve performances for huge dataset.

Parameters:index_data_list – List of Index in the data
Returns:List of index of the graph
set_permutations(self, permutations)[source]

Set permutations between datapoints of the trace

Parameters:permutations – list of indices to plot (example: [0, 2, 1] means that the first point will be plotted, then the third, then the second one)
get_x_label(self)[source]

Get x label of the trace

get_y_label(self)[source]

Get y label of the trace

get_legend(self)[source]

Get name of the trace

get_symbol(self)[source]

Get symbol

add_point(self, x, y)[source]

Add point(s) to trace (inputs can be list or numeral)

delete_point(self, index_point)[source]

Delete a point from the datapoints

is_scattered(self)[source]

Delete a point from the datapoints

set_indices_points_to_plot(self, indices)[source]

Set indices points to plot

get_indices_points_to_plot(self)[source]

Get indices points to plot

get_linestyle(self)[source]

Get linestyle

__str__(self)[source]
export_str(self)[source]

Method to save the points constituting the trace

class Graph[source]

Simple graph container that contains several traces

add_trace(self, data)[source]

Add a trace to the graph

Parameters:dataData
Returns:id of the created trace
remove_trace(self, idTrace)[source]

Delete a trace from the graph

Parameters:idTrace – id of the trace to delete
get_trace(self, idTrace)[source]

Get data object of idTrace

Parameters:idTrace – id of the trace to get
Returns:Data
get_all_traces(self)[source]

Get all the traces id of the graph

export_str(self)[source]
class Graphs[source]

Contains several Graph

updateChildren(self)[source]
add_trace_firstGraph(self, data, updateChildren=True)[source]

Same as add_trace, but only if graphs has only one id :param data: :param updateChildren: :return:

add_trace(self, idGraph, data, updateChildren=True)[source]

Add a trace to the graph

Parameters:
  • idGraph – id of the graph
  • dataData
  • updateChildren – Automatically calls callback functions
Returns:

id of the created trace

remove_trace(self, idGraph, idTrace, updateChildren=True)[source]

Remove the trace from the graph

Parameters:
  • idGraph – id of the graph
  • idTrace – id of the trace to remove
  • updateChildren – Automatically calls callback functions
get_first_graph(self)[source]

Get id of the first graph

Returns:id of the first graph
get_graph(self, idGraph)[source]

Get graph object at idgraph

Parameters:idGraph – id of the graph to get
Returns:Graph
get_all_graphs_ids(self)[source]

Get all ids of the graphs

Returns:list of id graphs
get_all_graphs(self)[source]

Get all graphs. Return dict {id: Graph}

add_graph(self, updateChildren=True)[source]

Add a new graph

Returns:id of the created graph
remove_graph(self, idGraph)[source]

Delete a graph

Parameters:idGraph – id of the graph to delete
add_update_method(self, childObject)[source]

Add a callback each time a graph is modified.

Parameters:childObject – method without arguments
export_str(self)[source]

Export all the graphs in text

Returns:str
merge(self, otherGraphs)[source]
reset(self)[source]
SHOW_WARNING = 0
SHOW_INFO = 1
SHOW_ERROR = 2
SHOW_DEBUG = 3
SHOW_CURRENT
class InterfaceDevice[source]

Interface class that represents a device. Hidden feature: variables that need to be saved must be type-hinted: e.g.: x: int. See obj_to_json() for more info

assign(self, machine_to_assign, resetAttribute=False)[source]

Copy the attribute values of machine_to_assign to self. The references are not lost.

Parameters:
  • machine_to_assignInterfaceDevice
  • resetAttribute
class HowToPlotGraph(attribute_x, attribute_y, kwargs_graph=None, excluded=None)[source]
exclude_col(self, id_col)[source]

Add id_col to exclude from the graph

__str__(self)[source]
class CollectionInfo(theCollection, kwargs, theID)[source]
get_collection(self)[source]
get_kwargs(self)[source]
get_id(self)[source]
class LinkDataGraph[source]
class _collection_linker[source]
get_collection_master(self, idToGet)[source]
is_slave(self, idToCheck)[source]
set_same_master(self, idExistingSlave, idOtherSlave)[source]
Parameters:
  • idExistingSlave – id collection of the existing slave
  • idOtherSlave – id collection of the new slave that has to be linked to an existing master
add_collection(self, theCollection, kwargs=None)[source]
add_graph(self, howToPlotGraph)[source]
createGraphs(self)[source]
get_howToPlotGraph(self, idGraph)[source]
get_collectionInfo(self, idCollectionInfo)[source]
create_trace(self, collectionInfo, howToPlotGraph, idGraph)[source]
get_all_id_graphs(self)[source]
get_all_traces_id_graph(self, idGraph)[source]
update_graphs(self)[source]
is_slave(self, idGraph, idTrace)[source]
get_idCollection_from_graph(self, idGraph, idTrace, getMaster=True)[source]

From indices in the graph, get index of corresponding collection

get_collection_from_graph(self, idGraph, idTrace, getMaster=True)[source]

From indices in the graph, get corresponding collection

get_dataObject_from_graph(self, idGraph, idTrace, idPoint)[source]
get_dataObjects_from_graph(self, idGraph, idTrace, idPoint_list)[source]
remove_element_from_graph(self, idGraph, idTrace, idPoint, deleteFromMaster=False)[source]

Remove element from the graph, or the master collection

remove_elements_from_trace(self, idGraph, idTrace, idPoints, deleteFromMaster=False)[source]

Performances optimisation when compared to LinkDataGraph.remove_element_from_graph()

Link data :param id_collection_graph: :param id_collection_master: :return:

remove_trace(self, idGraph, idTrace)[source]
get_graph_and_trace_from_collection(self, idCollection)[source]

Reverse search: from a collection, get the associated graph

get_mappingData_graph(self, idGraph)[source]
get_mappingData_trace(self, idGraph, idTrace)[source]
class text_format[source]
PURPLE = 
CYAN = 
DARKCYAN = 
BLUE = 
GREEN = 
YELLOW = 
WHITE = 
RED = 
BOLD = 
UNDERLINE = 
END = 
class Options[source]
get_name(self, idOption)[source]
get_value(self, idOption)[source]
add_option(self, idOption, name, value)[source]
set_option(self, idOption, value)[source]
copy(self)[source]
set_self(self, the_options)[source]
__str__(self)[source]
class Option_class[source]
get_optionValue(self, optionId)[source]
set_optionValue(self, optionId, value)[source]
get_all_options(self)[source]
set_all_options(self, options)[source]
add_option(self, idOption, name, value)[source]