core¶
Subpackages¶
Package Contents¶
-
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
-
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)
-
SHOW_WARNING
= 0¶
-
class
AutosaveStruct
(dataStruct, filename='', change_filename_if_exists=True)[source]¶ Structure that provides automated save of DataStructures
-
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()
-
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
-
-
class
text_format
[source]¶ -
PURPLE
= [95m¶
-
CYAN
= [96m¶
-
DARKCYAN
= [36m¶
-
BLUE
= [94m¶
-
GREEN
= [92m¶
-
YELLOW
= [93m¶
-
WHITE
= [30m¶
-
RED
= [91m¶
-
BOLD
= [1m¶
-
UNDERLINE
= [4m¶
-
END
= [0m¶
-
-
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)
-
getPath_workspace
()[source]
-
printIfShown
(theStr, show_type=SHOW_DEBUG, isToPrint=True, appendTypeName=True)[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))
-
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.
-
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
-
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)
-
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
-
-
class
Graph
[source]¶ Simple graph container that contains several traces
-
add_trace
(self, data)[source]¶ Add a trace to the graph
Parameters: data – Data
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
-
-
class
Graphs
[source]¶ Contains several
Graph
-
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
- data –
Data
- 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_graph
(self, idGraph)[source]¶ Get graph object at idgraph
Parameters: idGraph – id of the graph to get Returns: Graph
-
-
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
-
class
LinkDataGraph
[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
-
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_collection_to_graph_collection
(self, id_collection_graph, id_collection_master)[source]¶ Link data :param id_collection_graph: :param id_collection_master: :return:
-
-
class
text_format
[source] -
PURPLE
= [95m
-
CYAN
= [96m
-
DARKCYAN
= [36m
-
BLUE
= [94m
-
GREEN
= [92m
-
YELLOW
= [93m
-
WHITE
= [30m
-
RED
= [91m
-
BOLD
= [1m
-
UNDERLINE
= [4m
-
END
= [0m
-