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. Inheritance of annotation is managed by this function
-
json_to_obj
(json_dict)[source]¶ Convenience class to create object from dictionary. Only works if CLASS_TAG is valid
- Parameters
json_dict – dictionary loaded from a json file.
- Raises
TypeError – if class can not be found
KeyError – if CLASS_TAG not present in dictionary
-
json_to_obj_safe
(json_dict, cls)[source]¶ Safe class to create object from dictionary.
- Parameters
json_dict – dictionary loaded from a json file
cls – class object to instantiate with dictionary
-
get_json_module_tree
(theObj)[source]¶ Return dict containing {CLASS_TAG: “class_name”, MODULE_TAG: “module_name”, “attribute1”:{“class_name”: “module_name”, …}}
-
MODULE_TAG
= __module__¶
-
CLASS_TAG
= __class__¶
-
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¶
-
SHOW_DEBUG
= 3¶
-
class
AutosaveStruct
(dataStruct, filename='', change_filename_if_exists=True)[source]¶ Structure that provides automated save of DataStructures
-
class
ListDataStruct
(compress_save=False)[source]¶ Bases:
optimeed.core.collection.DataStruct_Interface
-
_INFO_STR
= info¶
-
_DATA_STR
= data¶
-
_COMPRESS_SAVE_STR
= module_tree¶
-
save
(self, filename)[source]¶ Save data using json format. The data to be saved are automatically detected, see
obj_to_json()
-
_format_str_save
(self)[source]¶ Save data using json format. The data to be saved are automatically detected, see
obj_to_json()
-
static
load
(filename, theClass=None)[source]¶ Load the file filename.
- Parameters
filename – file to load
theClass – optional. Can be used to fix unpickling errors.
- Returns
self-like object
-
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]
-
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.
-
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, x=None)[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
-
-
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
HowToPlotGraph
(attribute_x, attribute_y, kwargs_graph=None, excluded=None, exclusively=None, check_if_plot_elem=None)[source]¶
-
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
Option_class_interface
[source]¶ Bases:
abc.ABC
Interface of the class ‘Option_class’. It defines all the necessary methods to manage a set of options.
-
abstract
get_all_options
(self)[source]¶ Return a dictionnary containing tuples (name of the option, value of the option) :return: dict
-
abstract
-
class
Option_class_typed
[source]¶ Bases:
optimeed.core.options.Option_class_interface
-
my_names
:Dict[int, str]¶
-
my_map
:Dict[int, str]¶
-
my_options_0
:Dict[int, int]¶
-
my_options_1
:Dict[int, float]¶
-
my_options_2
:Dict[int, bool]¶
-
my_options_3
:Dict[int, str]¶
-
my_options_4
:Dict[int, List[int]]¶
-
my_options_5
:Dict[int, List[float]]¶
-
my_options_6
:Dict[int, List[str]]¶
-
my_options_7
:Dict[int, List[bool]]¶
-
static
__get_types
()¶
-
static
__match
(value, theType)¶
-
-
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_table
(x0, x_values, y_values)[source]¶ From sorted table (x,y) find y0 corresponding to x0 (linear interpolation)
-
reconstitute_signal
(amplitudes, phases, numberOfPeriods=1, x_points=None, n_points=50)[source]¶ Reconstitute the signal from fft. Number of periods of the signal must be specified if different of 1
-
my_fft
(y)[source]¶ Real FFT of signal Bx, with real amplitude of harmonics. Input signal must be within a period.
-
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_ellipse_axes
(a, b, dphi)[source]¶ Trouve les longueurs des axes majeurs et mineurs de l’ellipse, ainsi que l’orientation de l’ellipse. ellipse: x(t) = A*cos(t), y(t) = B*cos(t+dphi) Etapes: longueur demi ellipse CENTRéE = sqrt(a^2 cos^2(x) + b^2 cos^2(t+phi) Minimisation de cette formule => obtention formule tg(2x) = alpha/beta
-
rgetattr
(obj, attr)[source] Recursively get an attribute from object. Extends getattr method
- Parameters
obj – object
attr – attribute to get
- Returns
-
rsetattr
(obj, attr, val)[source]
-
MODULE_TAG
= __module__
-
CLASS_TAG
= __class__
-
EXCLUDED_TAGS
¶
-
class
SaveableObject
[source]¶ Abstract class for dynamically type-hinted objects. This class is to solve the special case where the exact type of an attribute is not known before runtime, yet has to be saved.
-
_get_object_class
(theObj)¶
-
_get_object_module
(theObj)¶
-
_object_to_FQCN
(theobj)¶ Gets module path of object
-
_find_class
(moduleName, className)¶
-
json_to_obj
(json_dict)[source] Convenience class to create object from dictionary. Only works if CLASS_TAG is valid
- Parameters
json_dict – dictionary loaded from a json file.
- Raises
TypeError – if class can not be found
KeyError – if CLASS_TAG not present in dictionary
-
json_to_obj_safe
(json_dict, cls)[source] Safe class to create object from dictionary.
- Parameters
json_dict – dictionary loaded from a json file
cls – class object to instantiate with dictionary
-
_instantiates_annotated_object
(_json_dict, _cls)¶
-
_get_annotations
(theObj)¶ Return annotated attributes
-
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. Inheritance of annotation is managed by this function
-
_get_attributes_to_save
(theObj)¶ Return list (attribute, is_first)
-
get_json_module_tree
(theObj)[source] Return dict containing {CLASS_TAG: “class_name”, MODULE_TAG: “module_name”, “attribute1”:{“class_name”: “module_name”, …}}
-
encode_str_json
(theStr)[source]
-
decode_str_json
(theStr)[source]
-
export_to_tikz_groupGraphs
(theGraphs: Graphs, foldername, additionalPreamble=lambda: '', additionalAxisOptions=lambda graphId: '', additionalTraceOptions=lambda graphId, traceId: '', debug=False)[source]¶ Export the graphs as group
- Parameters
theGraphs – Graphs to save
foldername – Foldername to save
additionalPreamble – method that returns string for custom tikz options
additionalAxisOptions – method that returns string for custom tikz options
additionalTraceOptions – method that returns string for custom tikz options
- Returns