core¶
Subpackages¶
Package Contents¶
Classes¶
Functions¶
Attributes¶
-
_workspace_path
¶
-
create_unique_dirname
(dirname)[source]¶ Create dirname if it doesn’t exists, otherwise append an integer to dirname and create it.
Parameters: dirname – name of the directory to create Returns: name of the directory created
-
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]¶ Get workspace path (i.e., location where optimeed files will be created). Create directory if doesn’t exist.
-
setPath_workspace
(thePath)[source]¶ Set workspace path (i.e., location where optimeed files will be created)
-
rsetattr
(obj, attr, val)[source]¶ setattr, but recursively. Works with list (i.e. theObj.myList[0].var_x)
-
indentParagraph
(text_in, indent_level=1)[source]¶ Add ‘ ‘ at beginning of strings and after each ‘ ‘.
-
get_2D_pareto
(xList, yList, max_X=True, max_Y=True)[source]¶ Get 2D pareto front
Parameters: - xList – list of x coordinates
- yList – list of y coordinates
- max_X – True if x is to maximize
- max_Y – true if y is to maximize
Returns: x pareto-optimal coordinates, y pareto-optimal coordinates, indices of these points in input parameters
-
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
Parameters: - indices – list
- theList – list
-
merge_two_dicts
(dict1, dict2)[source]¶ Merge two dicts without affecting them
Returns: new dictionary
-
SHOW_CURRENT
¶
-
SHOW_CURRENT
-
setCurrentShow
(show_types)[source] Change text type to be displayed by PrintIfShown
-
getCurrentShow
()[source] Get text type to be displayed by PrintIfShown
-
disableLogs
()[source] Disable all logs
-
enableLogs
()[source] Show all logs
-
getPath_workspace
()[source] Get workspace path (i.e., location where optimeed files will be created). Create directory if doesn’t exist.
-
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_from_dict
(jsonDict)[source]¶ Return dict containing {CLASS_TAG: “class_name”, MODULE_TAG: “module_name”, “attribute1”:{“class_name”: “module_name”, …}}
-
remove_module_tree_from_string
(theStr)[source]¶ Used to compress string by removing __module__ and __class__ entries (used with get_json_module_tree_from_dict)
-
apply_module_tree_to_dict
(nestedTree, nestedObject, raiseError=False)[source]¶ Restore __module__ and __class__ entries from nestedTree in nestedDict
-
indentParagraph
(text_in, indent_level=1)[source] Add ‘ ‘ at beginning of strings and after each ‘ ‘.
-
rgetattr
(obj, attr)[source] getattr, but recursively. Works with list.
-
printIfShown
(theStr, show_type=SHOW_DEBUG, isToPrint=True, appendTypeName=True, end='n')[source]
-
delete_indices_from_list
(indices, theList)[source] Delete elements from list at indices
Parameters: - indices – list
- theList – list
-
class
ListDataStruct_Interface
[source]¶ Bases:
DataStruct_Interface
-
class
AutosaveStruct
(dataStruct, filename='', change_filename_if_exists=True)[source]¶ Structure that provides automated save of DataStructures
-
class
ListDataStruct
(compress_save=False)[source]¶ Bases:
ListDataStruct_Interface
-
save
(filename)[source]¶ Save data using json format. The data to be saved are automatically detected, see
obj_to_json()
-
extract_collection_from_indices
(indices)[source]¶ Extract data from the collection at specific indices, and return it as new collection
-
_format_str_save
()[source]¶ Save data using json format. The data to be saved are automatically detected, see
obj_to_json()
-
extract_collection_from_attribute
(attributeName)[source]¶ Convenience class to create a sub-collection from an attribute of all the items.
Parameters: attributeName – Name of the attribute to extract Returns: ListDataStruct
-
delete_points_at_indices
(indices)[source]¶ Delete several elements from the Collection
Parameters: indices – list of indices to delete
-
-
theLock
¶
-
class
Performance_ListDataStruct
(stack_size=500)[source]¶ Bases:
ListDataStruct_Interface
-
extract_collection_from_indices
(indices)[source]¶ Extract data from the collection at specific indices, and return it as new collection
-
_get_json_str_at_index
(index, refresh_cache=False)[source]¶ Internal method to return the json string at index
-
get_attribute_value_at_index_fast
(attribute, index)[source]¶ Experimental method to extract the value of an attribute without converting the string to an object. It is based on regex search, and will fail if the element is the last in string.
Parameters: - attribute – attribute to search
- index – index of the element in collection
Returns:
-
reorder
(permutations)[source]¶ Reorder collection accordingly to permutations. E.G, permutations [0,2,1] with collection elems [0,3,2] => collection elems = [0,2,3] :param permutations: :return: /
-
get_data_at_index
(index, ignore_attributes=None, none_if_error=False)[source]¶ Same as parent, with additional kwargs
Parameters: - index –
- ignore_attributes – ignore attributes to deserialize (list)
- none_if_error –
Returns:
-
-
printIfShown
(theStr, show_type=SHOW_DEBUG, isToPrint=True, appendTypeName=True, end='n')[source]
-
convert_color_with_alpha
(color, alpha=255)[source]¶ Same as meth:convert_color but with transparency
-
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, alpha=255, symbol='o', symbolsize=8, fillsymbol=True, outlinesymbol=1.8, linestyle='-', width=2, meta=None)[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
()[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_plot_meta
(x, y)[source]¶ Call this method to get the z coordinates of the points that been displayed. => After transformation, and after permutations.
Returns: z (list)
-
get_permutations
(x=None)[source]¶ Return the transformation ‘permutation’: xplot[i] = xdata[permutation[i]]
-
get_dataIndex_from_graphIndex
(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
(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
(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
(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
(data)[source]¶ Add a trace to the graph
Parameters: data – Data
Returns: id of the created trace
-
remove_trace
(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
(data, updateChildren=True)[source]¶ Same as add_trace, but only if graphs has only one id :param data: :param updateChildren: :return:
-
add_trace
(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
(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
(idGraph)[source]¶ Get graph object at idgraph
Parameters: idGraph – id of the graph to get Returns: Graph
-
-
class
Plot3D_Generic
(x_label='', y_label='', z_label='', legend='', x_lim=None, y_lim=None, z_lim=None)[source]¶
-
class
GridPlot_Generic
(X, Y, Z, **kwargs)[source]¶ Bases:
Plot3D_Generic
-
class
ContourPlot
(*args, **kwargs)[source]¶ Bases:
GridPlot_Generic
-
class
FilledContourPlot
(*args, **kwargs)[source]¶ Bases:
ContourPlot
-
class
SurfPlot
(X, Y, Z, **kwargs)[source]¶ Bases:
GridPlot_Generic
-
class
MeshPlot
(X, Y, Z, **kwargs)[source]¶ Bases:
GridPlot_Generic
-
class
ScatterPlot3
(x, y, z, **kwargs)[source]¶ Bases:
Plot3D_Generic
-
convert_to_gridplot
(x, y, z, x_interval=None, y_interval=None, n_x=20, n_y=20)[source]¶ Convert set of points x, y, z to a grid
Parameters: - x –
- y –
- z –
- x_interval – [Min, max] of the grid. If none, use min and max values
- y_interval – [Min, max] of the grid. If none, use min and max values
- n_x – number of points in x direction
- n_y – number of points in y direction
Returns: X, Y, Z as grid
-
class
HowToPlotGraph
(attribute_x, attribute_y, kwargs_graph=None, check_if_plot_elem=None, meta=None)[source]¶
-
class
LinkDataGraph
[source]¶ -
add_collection
(theCollection, kwargs=None)[source]¶ Add a collection (that will be a future trace)
Parameters: - theCollection –
- kwargs – kwargs associated with the collection (e.g., color, symbol style, etc.)
Returns: unique id associated with the collection
-
remove_collection
(collectionId)[source]¶ Remove collection from the graphs
Parameters: collectionId – ID of the collection Returns:
-
set_shadow_collection
(master_collectionId, shadow_collection)[source]¶ Link a collection to an other
Parameters: - master_collectionId – ID of the collection that is displayed in the graph
- shadow_collection – collection to link to the master.
Returns:
-
add_graph
(howToPlotGraph)[source]¶ Add new graph to be plotted.
Parameters: howToPlotGraph – HowToPlotGraph
Returns:
-
get_idCollection_from_graph
(idGraph, idTrace)[source]¶ Get id of collection plotted in graph $idGraph and trace $idTrace
-
get_collection_from_graph
(idGraph, idTrace, getShadow=True) → optimeed.core.ListDataStruct_Interface[source]¶ From indices in the graph, get corresponding collection
-
get_clicked_item
(idGraph, idTrace, idPoint, getShadow=True)[source]¶ Get the data hidden behind the clicked point
Parameters: - idGraph – ID of the graph
- idTrace – ID of the trace
- idPoint – ID of the point
- getShadow – If true, will return the data from the collection linked to the collection that is plotted
Returns: Object in collection
-
get_clicked_items
(idGraph, idTrace, idPoint_list, getShadow=True)[source]¶ Same as get_clicked_item, but using a list of points
-
get_graph_and_trace_from_idCollection
(idCollection)[source]¶ Reverse search: from a collection, get all associated graphs
-
get_idcollection_from_collection
(theCollection)[source]¶ Reverse search: from a collection, find its id
-
-
class
Option_bool
(name, based_value, choices=None)[source]¶ Bases:
Base_Option
-
class
Option_str
(name, based_value, choices=None)[source]¶ Bases:
Base_Option
-
class
Option_int
(name, based_value, choices=None)[source]¶ Bases:
Base_Option
-
class
Option_float
(name, based_value, choices=None)[source]¶ Bases:
Base_Option
-
class
Option_dict
(name, based_value, choices=None)[source]¶ Bases:
Base_Option
-
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
-
convert_color
(color)[source]¶ Convert a color to a tuple if color is a char, otherwise return the tuple.
Parameters: color – (r,g,b) or char. Returns:
-
convert_color_with_alpha
(color, alpha=255)[source] Same as meth:convert_color but with transparency
-
rgetattr
(obj, attr)[source] getattr, but recursively. Works with list.
-
rsetattr
(obj, attr, val)[source] setattr, but recursively. Works with list (i.e. theObj.myList[0].var_x)
-
printIfShown
(theStr, show_type=SHOW_DEBUG, isToPrint=True, appendTypeName=True, end='n')[source]
-
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.
-
_isclass
(theObject)¶ Extends the default isclass method with typing
-
_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 (theObj being the type of the object)
-
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_from_dict
(jsonDict)[source] Return dict containing {CLASS_TAG: “class_name”, MODULE_TAG: “module_name”, “attribute1”:{“class_name”: “module_name”, …}}
-
remove_module_tree_from_string
(theStr)[source] Used to compress string by removing __module__ and __class__ entries (used with get_json_module_tree_from_dict)
-
apply_module_tree_to_dict
(nestedTree, nestedObject, raiseError=False)[source] Restore __module__ and __class__ entries from nestedTree in nestedDict
-
encode_str_json
(theStr)[source]
-
decode_str_json
(theStr)[source]
-
export_to_tikz_groupGraphs
(theGraphs: optimeed.core.graphs.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:
-
export_to_tikz_contour_plot
(list_of_traces3, foldername, filename_data='data')[source]¶ Export the graphs as group
Parameters: - list_of_traces3 – List of 3D traces
- foldername – Foldername to save
- filename_data – filename of the data
Returns:
-
printIfShown
(theStr, show_type=SHOW_DEBUG, isToPrint=True, appendTypeName=True, end='n')[source]
-
inkscape_version
¶