**core** ======================= .. py:module:: optimeed.core Subpackages ----------- .. toctree:: :titlesonly: :maxdepth: 8 ansi2html/index.rst .. toctree:: :titlesonly: :maxdepth: 1 additional_tools/index.rst collection/index.rst color_palette/index.rst commonImport/index.rst graphs/index.rst graphs3/index.rst inkscape_manager/index.rst linkDataGraph/index.rst myjson/index.rst options/index.rst tikzTranslator/index.rst tools/index.rst Package Contents ---------------- Classes ~~~~~~~ .. autoapisummary:: optimeed.core.text_format optimeed.core.SingleObjectSaveLoad optimeed.core.DataStruct_Interface optimeed.core.ListDataStruct_Interface optimeed.core.AutosaveStruct optimeed.core.ListDataStruct optimeed.core.Performance_ListDataStruct optimeed.core.Data optimeed.core.Graph optimeed.core.Graphs optimeed.core.Plot3D_Generic optimeed.core.GridPlot_Generic optimeed.core.ContourPlot optimeed.core.FilledContourPlot optimeed.core.SurfPlot optimeed.core.MeshPlot optimeed.core.ScatterPlot3 optimeed.core.HowToPlotGraph optimeed.core.LinkDataGraph optimeed.core.Base_Option optimeed.core.Option_bool optimeed.core.Option_str optimeed.core.Option_int optimeed.core.Option_float optimeed.core.Option_dict optimeed.core.Option_class optimeed.core.fast_LUT_interpolation optimeed.core.SaveableObject Functions ~~~~~~~~~ .. autoapisummary:: optimeed.core.software_version optimeed.core.find_and_replace optimeed.core.create_unique_dirname optimeed.core.applyEquation optimeed.core.arithmeticEval optimeed.core.isNonePrintMessage optimeed.core.getPath_workspace optimeed.core.setPath_workspace optimeed.core.getLineInfo optimeed.core.printIfShown optimeed.core.universalPath optimeed.core.add_suffix_to_path optimeed.core.get_object_attrs optimeed.core.rsetattr optimeed.core.rgetattr optimeed.core.indentParagraph optimeed.core.truncate optimeed.core.get_recursive_attrs optimeed.core.str_all_attr optimeed.core.get_2D_pareto optimeed.core.get_ND_pareto optimeed.core.delete_indices_from_list optimeed.core.merge_two_dicts optimeed.core.deep_sizeof optimeed.core.order_lists optimeed.core.setCurrentShow optimeed.core.getCurrentShow optimeed.core.disableLogs optimeed.core.enableLogs optimeed.core.setCurrentShow optimeed.core.getCurrentShow optimeed.core.disableLogs optimeed.core.enableLogs optimeed.core.getPath_workspace optimeed.core.obj_to_json optimeed.core.json_to_obj optimeed.core.json_to_obj_safe optimeed.core.encode_str_json optimeed.core.decode_str_json optimeed.core.get_json_module_tree_from_dict optimeed.core.remove_module_tree_from_string optimeed.core.apply_module_tree_to_dict optimeed.core.indentParagraph optimeed.core.rgetattr optimeed.core.printIfShown optimeed.core.delete_indices_from_list optimeed.core.default_palette optimeed.core.blackOnly optimeed.core.dark2 optimeed.core.printIfShown optimeed.core.convert_color_with_alpha optimeed.core.convert_to_gridplot optimeed.core.interpolate_table optimeed.core.derivate optimeed.core.linspace optimeed.core.reconstitute_signal optimeed.core.my_fft optimeed.core.cart2pol optimeed.core.pol2cart optimeed.core.partition optimeed.core.quicksort optimeed.core.dist optimeed.core.sparse_subset optimeed.core.integrate optimeed.core.my_fourier optimeed.core.get_ellipse_axes optimeed.core.convert_color optimeed.core.convert_color_with_alpha optimeed.core.rgetattr optimeed.core.rsetattr optimeed.core.printIfShown optimeed.core.getExecPath optimeed.core._isclass optimeed.core.get_type_class optimeed.core._get_object_class optimeed.core._get_object_module optimeed.core._object_to_FQCN optimeed.core._find_class optimeed.core.json_to_obj optimeed.core.json_to_obj_safe optimeed.core._instantiates_annotated_object optimeed.core._get_annotations optimeed.core.obj_to_json optimeed.core._get_attributes_to_save optimeed.core.get_json_module_tree_from_dict optimeed.core.remove_module_tree_from_string optimeed.core.apply_module_tree_to_dict optimeed.core.encode_str_json optimeed.core.decode_str_json optimeed.core.export_to_tikz_groupGraphs optimeed.core.export_to_tikz_contour_plot optimeed.core.printIfShown optimeed.core.get_path_to_inkscape optimeed.core.get_inkscape_version optimeed.core.inkscape_svg_to_pdf optimeed.core.inkscape_svg_to_png Attributes ~~~~~~~~~~ .. autoapisummary:: optimeed.core._workspace_path optimeed.core.SHOW_WARNING optimeed.core.SHOW_INFO optimeed.core.SHOW_ERROR optimeed.core.SHOW_DEBUG optimeed.core.SHOW_LOGS optimeed.core.SHOW_CURRENT optimeed.core.SHOW_WARNING optimeed.core.SHOW_INFO optimeed.core.SHOW_ERROR optimeed.core.SHOW_DEBUG optimeed.core.SHOW_LOGS optimeed.core.SHOW_CURRENT optimeed.core.SHOW_WARNING optimeed.core.SHOW_DEBUG optimeed.core.SHOW_INFO optimeed.core.SHOW_ERROR optimeed.core.theLock optimeed.core.SHOW_WARNING optimeed.core.griddata_found optimeed.core.has_scipy optimeed.core.SHOW_ERROR optimeed.core.SHOW_WARNING optimeed.core.MODULE_TAG optimeed.core.CLASS_TAG optimeed.core.EXCLUDED_TAGS optimeed.core.SHOW_WARNING optimeed.core.inkscape_version .. py:data:: _workspace_path .. py:class:: text_format .. py:attribute:: PURPLE :value: '\x1b[95m' .. py:attribute:: CYAN :value: '\x1b[96m' .. py:attribute:: DARKCYAN :value: '\x1b[36m' .. py:attribute:: BLUE :value: '\x1b[94m' .. py:attribute:: GREEN :value: '\x1b[92m' .. py:attribute:: YELLOW :value: '\x1b[93m' .. py:attribute:: WHITE :value: '\x1b[30m' .. py:attribute:: RED :value: '\x1b[91m' .. py:attribute:: BOLD :value: '\x1b[1m' .. py:attribute:: UNDERLINE :value: '\x1b[4m' .. py:attribute:: END :value: '\x1b[0m' .. py:function:: software_version() .. py:function:: find_and_replace(begin_char, end_char, theStr, replace_function) .. py:function:: create_unique_dirname(dirname) Create dirname if it doesn't exists, otherwise append an integer to dirname and create it. :param dirname: name of the directory to create :return: name of the directory created .. py:function:: applyEquation(objectIn, s) Apply literal expression based on an object :param objectIn: Object :param 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. :return: value (float) .. py:function:: arithmeticEval(s) .. py:function:: isNonePrintMessage(theObject, theMessage, show_type=SHOW_INFO) .. py:function:: getPath_workspace() Get workspace path (i.e., location where optimeed files will be created). Create directory if doesn't exist. .. py:function:: setPath_workspace(thePath) Set workspace path (i.e., location where optimeed files will be created) .. py:function:: getLineInfo(lvl=1) .. py:function:: printIfShown(theStr, show_type=SHOW_DEBUG, isToPrint=True, appendTypeName=True, end='\n') .. py:function:: universalPath(thePath) .. py:function:: add_suffix_to_path(thePath, suffix) .. py:function:: get_object_attrs(obj) .. py:function:: rsetattr(obj, attr, val) setattr, but recursively. Works with list (i.e. theObj.myList[0].var_x) .. py:function:: rgetattr(obj, attr) getattr, but recursively. Works with list. .. py:function:: indentParagraph(text_in, indent_level=1) Add ' ' at beginning of strings and after each ' '. .. py:function:: truncate(theStr, truncsize) .. py:function:: get_recursive_attrs(theObject, max_recursion_level=2) .. py:function:: str_all_attr(theObject, max_recursion_level) .. py:function:: get_2D_pareto(xList, yList, max_X=True, max_Y=True) Get 2D pareto front :param xList: list of x coordinates :param yList: list of y coordinates :param max_X: True if x is to maximize :param max_Y: true if y is to maximize :return: x pareto-optimal coordinates, y pareto-optimal coordinates, indices of these points in input parameters .. py:function:: get_ND_pareto(objectives_list, are_maxobjectives_list=None) Return the N-D pareto front :param objectives_list: list of list of objectives: example [[0,1], [1,1], [2,2]] :param are_maxobjectives_list: for each objective, tells if they are to be maximized or not: example [True, False]. Default: False :return: extracted_pareto, indices: list of [x, y, ...] points forming the pareto front, and list of the indices of these points from the base list. .. py:function:: delete_indices_from_list(indices, theList) Delete elements from list at indices :param indices: list :param theList: list .. py:function:: merge_two_dicts(dict1, dict2) Merge two dicts without affecting them :return: new dictionary .. py:function:: deep_sizeof(obj) .. py:function:: order_lists(ref_list, linked_list) .. py:data:: SHOW_WARNING :value: 0 .. py:data:: SHOW_INFO :value: 1 .. py:data:: SHOW_ERROR :value: 2 .. py:data:: SHOW_DEBUG :value: 3 .. py:data:: SHOW_LOGS :value: 4 .. py:data:: SHOW_CURRENT .. py:function:: setCurrentShow(show_types) Change text type to be displayed by PrintIfShown .. py:function:: getCurrentShow() Get text type to be displayed by PrintIfShown .. py:function:: disableLogs() Disable all logs .. py:function:: enableLogs() Show all logs .. py:data:: SHOW_WARNING :value: 0 .. py:data:: SHOW_INFO :value: 1 .. py:data:: SHOW_ERROR :value: 2 .. py:data:: SHOW_DEBUG :value: 3 .. py:data:: SHOW_LOGS :value: 4 .. py:data:: SHOW_CURRENT .. py:function:: setCurrentShow(show_types) Change text type to be displayed by PrintIfShown .. py:function:: getCurrentShow() Get text type to be displayed by PrintIfShown .. py:function:: disableLogs() Disable all logs .. py:function:: enableLogs() Show all logs .. py:function:: getPath_workspace() Get workspace path (i.e., location where optimeed files will be created). Create directory if doesn't exist. .. py:function:: obj_to_json(theObj) 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 .. py:function:: json_to_obj(json_dict) 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 .. py:function:: json_to_obj_safe(json_dict, cls) Safe class to create object from dictionary. :param json_dict: dictionary loaded from a json file :param cls: class object to instantiate with dictionary .. py:function:: encode_str_json(theStr) .. py:function:: decode_str_json(theStr) .. py:function:: get_json_module_tree_from_dict(jsonDict) Return dict containing {CLASS_TAG: "class_name", MODULE_TAG: "module_name", "attribute1":{"class_name": "module_name", ...}} .. py:function:: remove_module_tree_from_string(theStr) Used to compress string by removing __module__ and __class__ entries (used with get_json_module_tree_from_dict) .. py:function:: apply_module_tree_to_dict(nestedTree, nestedObject, raiseError=False) Restore __module__ and __class__ entries from nestedTree in nestedDict .. py:function:: indentParagraph(text_in, indent_level=1) Add ' ' at beginning of strings and after each ' '. .. py:function:: rgetattr(obj, attr) getattr, but recursively. Works with list. .. py:function:: printIfShown(theStr, show_type=SHOW_DEBUG, isToPrint=True, appendTypeName=True, end='\n') .. py:data:: SHOW_WARNING :value: 0 .. py:data:: SHOW_DEBUG :value: 3 .. py:data:: SHOW_INFO :value: 1 .. py:data:: SHOW_ERROR :value: 2 .. py:function:: delete_indices_from_list(indices, theList) Delete elements from list at indices :param indices: list :param theList: list .. py:class:: SingleObjectSaveLoad .. py:method:: load(filename) :staticmethod: .. py:method:: save(theObject, filename) :staticmethod: .. py:class:: DataStruct_Interface .. py:method:: save(filename) :abstractmethod: Save the datastructure to filename .. py:method:: clone(filename) :abstractmethod: Clone the datastructure to a new location .. py:method:: load(filename, **kwargs) :staticmethod: :abstractmethod: Load the datastructure from filename .. py:method:: get_extension() :staticmethod: File extension used for datastructure .. py:method:: __str__() Return str(self). .. py:class:: ListDataStruct_Interface Bases: :py:obj:`DataStruct_Interface` .. py:method:: add_data(data_in) :abstractmethod: .. py:method:: get_data_at_index(index) :abstractmethod: .. py:method:: get_data_generator() :abstractmethod: .. py:method:: delete_points_at_indices(indices) :abstractmethod: Delete several elements from the Collection :param indices: list of indices to delete .. py:method:: get_nbr_elements() :abstractmethod: :return: the number of elements contained inside the structure .. py:method:: extract_collection_from_indices(theIndices) :abstractmethod: Extract data from the collection at specific indices, and return it as new collection :param theIndices: :return: A new collection .. py:method:: _jsondata_to_obj(item, theClass=None) :staticmethod: .. py:method:: get_list_attributes(attributeName) Get the value of attributeName of all the data in the Collection :param attributeName: string (name of the attribute to get) :return: list .. py:class:: AutosaveStruct(dataStruct, filename='', change_filename_if_exists=True) Structure that provides automated save of DataStructures .. py:method:: __str__() Return str(self). .. py:method:: get_filename() Get set filename .. py:method:: set_filename(filename, change_filename_if_exists) :param filename: Filename to set :param change_filename_if_exists: If already exists, create a new filename .. py:method:: stop_autosave() Stop autosave .. py:method:: start_autosave(timer_autosave, safe_save=True) Start autosave .. py:method:: save(safe_save=True) Save .. py:method:: get_datastruct() Return :class:'~DataStruct_Interface' .. py:method:: __getstate__() .. py:method:: __setstate__(state) .. py:class:: ListDataStruct(compress_save=False) Bases: :py:obj:`ListDataStruct_Interface` .. py:attribute:: _DATA_STR :value: 'data' .. py:attribute:: _COMPRESS_SAVE_STR :value: 'module_tree' .. py:method:: __len__() .. py:method:: get_length() .. py:method:: clone(filename) Clone the datastructure to a new location .. py:method:: save(filename) Save data using json format. The data to be saved are automatically detected, see :meth:`~optimeed.core.myjson.obj_to_json` .. py:method:: extract_collection_from_indices(indices) Extract data from the collection at specific indices, and return it as new collection .. py:method:: _format_str_save() Save data using json format. The data to be saved are automatically detected, see :meth:`~optimeed.core.myjson.obj_to_json` .. py:method:: _format_data_lines() .. py:method:: _get_json_module_tree() .. py:method:: load(filename, theClass=None) :staticmethod: Load the file filename. :param filename: file to load :param theClass: optional. Can be used to fix unpickling errors. :return: self-like object .. py:method:: add_data(data_in) Add a data to the list .. py:method:: get_data() Get full list of datas .. py:method:: get_data_generator() Get a generator to all the data stored .. py:method:: get_data_at_index(index) .. py:method:: set_data(theData) Set full list of datas .. py:method:: set_data_at_index(data_in, index) Replace data at specific index .. py:method:: extract_collection_from_attribute(attributeName) Convenience class to create a sub-collection from an attribute of all the items. :param attributeName: Name of the attribute to extract :return: ListDataStruct .. py:method:: reset_data() .. py:method:: delete_points_at_indices(indices) Delete several elements from the Collection :param indices: list of indices to delete .. py:method:: merge(collection) Merge a collection with the current collection :param collection: :class:`~optimeed.core.Collection.Collection` to merge .. py:method:: get_nbr_elements() :return: the number of elements contained inside the structure .. py:data:: theLock .. py:class:: Performance_ListDataStruct(stack_size=500) Bases: :py:obj:`ListDataStruct_Interface` .. py:attribute:: _NBR_ELEMENTS :value: 'nbr_elements' .. py:attribute:: _STACK_SIZE :value: 'stack_size' .. py:attribute:: _COMPRESS_SAVE_STR :value: 'module_tree' .. py:method:: _initialize(filename) .. py:method:: _get_subfolder_path(main_filename) :staticmethod: .. py:method:: _get_list_from_file(filenumber) .. py:method:: _get_path_from_filenumber(main_filename, filenumber) :staticmethod: .. py:method:: split_list(numb_in_list, stack_size, thing_to_hash) :staticmethod: .. py:method:: extract_collection_from_indices(indices) Extract data from the collection at specific indices, and return it as new collection .. py:method:: clone(filename) Clone the datastructure to a new location .. py:method:: _get_str_mainfile() .. py:method:: get_total_nbr_elements(count_unsaved=True) .. py:method:: add_data(theData) Add data to the collection .. py:method:: add_json_data(theStr) Add already deserialized data to the collection .. py:method:: _save_moduletree(theDict) .. py:method:: _map_index_to_file(index) .. py:method:: _get_json_str_at_index(index, refresh_cache=False) Internal method to return the json string at index .. py:method:: get_attribute_value_at_index_fast(attribute, index) 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. :param attribute: attribute to search :param index: index of the element in collection :return: .. py:method:: reorder(permutations) 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: / .. py:method:: get_data_at_index(index, ignore_attributes=None, none_if_error=False) Same as parent, with additional kwargs :param index: :param ignore_attributes: ignore attributes to deserialize (list) :param none_if_error: :return: .. py:method:: save(filename) Save the datastructure to filename .. py:method:: load(filename, **kwargs) :staticmethod: Load the datastructure from filename .. py:method:: load_as_listdatastruct(filename, **kwargs) :staticmethod: Return :class:`ListDataStruct`. Serializes all objects of collection .. py:method:: get_data_generator(**kwargs) .. py:method:: get_nbr_elements() :return: the number of elements contained inside the structure .. py:method:: set_data_at_index(data_in, index) Replace data at specific index .. py:method:: set_data_at_indices(data_list, indices) Replace datas at specific indices :param data_list: list of objects to set to the collection, at specific indices :param indices: list of indices :return: .. py:method:: delete_points_at_indices(indices) Delete several elements from the Collection :param indices: list of indices to delete .. py:function:: default_palette(N) .. py:function:: blackOnly(N) .. py:function:: dark2(N) .. py:function:: printIfShown(theStr, show_type=SHOW_DEBUG, isToPrint=True, appendTypeName=True, end='\n') .. py:data:: SHOW_WARNING :value: 0 .. py:function:: convert_color_with_alpha(color, alpha=255) Same as meth:`convert_color` but with transparency .. py: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) 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) .. py:method:: set_kwargs(kwargs) Set a kwarg after creation of the class .. py:method:: set_data(x: list, y: list) Overwrites current datapoints with new set .. py:method:: set_meta(meta) Set associated 'Z' data .. py:method:: get_x() Get x coordinates of datapoints .. py:method:: get_symbolsize() Get size of the symbols .. py:method:: symbol_isfilled() Check if symbols has to be filled or not .. py:method:: get_symbolOutline() Get color factor of outline of symbols .. py:method:: get_length_data() Get number of points .. py:method:: get_xlim() Get x limits of viewbox .. py:method:: get_ylim() Get y limits of viewbox .. py:method:: get_y() Get y coordinates of datapoints .. py:method:: get_meta() Get associated 'Z' data .. py:method:: get_color() Get color of the line, without transformation .. py:method:: get_color_alpha() Get color of the line. Return r, g, b in 0, 255 scale .. py:method:: get_alpha() Get opacity .. py:method:: get_width() Get width of the line .. py:method:: get_number_of_points() Get number of points .. py:method:: get_plot_data() Call this method to get the x and y coordinates of the points that have to be displayed. => After transformation, and after permutations. :return: x (list), y (list) .. py:method:: get_plot_meta(x, y) Call this method to get the z coordinates of the points that been displayed. => After transformation, and after permutations. :return: z (list) .. py:method:: get_permutations(x=None) Return the transformation 'permutation': xplot[i] = xdata[permutation[i]] .. py:method:: get_invert_permutations() Return the inverse of permutations: xdata[i] = xplot[revert[i]] .. py:method:: get_dataIndex_from_graphIndex(index_graph_point) From an index given in graph, recovers the index of the data. :param index_graph_point: Index in the graph :return: index of the data .. py:method:: get_dataIndices_from_graphIndices(index_graph_point_list) Same as get_dataIndex_from_graphIndex but with a list in entry. Can (?) improve performances for huge dataset. :param index_graph_point_list: List of Index in the graph :return: List of index of the data .. py:method:: get_graphIndex_from_dataIndex(index_data) From an index given in the data, recovers the index of the graph. :param index_data: Index in the data :return: index of the graph .. py:method:: get_graphIndices_from_dataIndices(index_data_list) Same as get_graphIndex_from_dataIndex but with a list in entry. Can (?) improve performances for huge dataset. :param index_data_list: List of Index in the data :return: List of index of the graph .. py:method:: set_permutations(permutations) Set permutations between datapoints of the trace :param 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) .. py:method:: get_x_label() Get x label of the trace .. py:method:: get_y_label() Get y label of the trace .. py:method:: get_legend() Get name of the trace .. py:method:: get_symbol() Get symbol .. py:method:: add_point(x, y) Add point(s) to trace (inputs can be list or numeral) .. py:method:: delete_point(index_point) Delete a point from the datapoints .. py:method:: isScattered() Check if plot is scatteded .. py:method:: set_indices_points_to_plot(indices) Set indices points to plot .. py:method:: get_indices_points_to_plot() Get indices points to plot .. py:method:: get_linestyle() Get linestyle .. py:method:: __str__() Return str(self). .. py:method:: export_str() Method to save the points constituting the trace .. py:method:: set_color(theColor) Set trace color .. py:method:: set_legend(theLegend) Set legend .. py:class:: Graph Simple graph container that contains several traces .. py:method:: add_trace(data) Add a trace to the graph :param data: :class:`~Data` :return: id of the created trace .. py:method:: remove_trace(idTrace) Delete a trace from the graph :param idTrace: id of the trace to delete .. py:method:: get_trace(idTrace) -> Data Get data object of idTrace :param idTrace: id of the trace to get :return: :class:`~Data` .. py:method:: get_all_traces() Get all the traces id of the graph .. py:method:: get_all_traces_ids() Get all the traces id of the graph :return: list of id graphs .. py:method:: export_str() .. py:class:: Graphs Contains several :class:`Graph` .. py:method:: updateChildren() .. py:method:: add_trace_firstGraph(data, updateChildren=True) Same as add_trace, but only if graphs has only one id :param data: :param updateChildren: :return: .. py:method:: add_trace(idGraph, data, updateChildren=True) Add a trace to the graph :param idGraph: id of the graph :param data: :class:`~Data` :param updateChildren: Automatically calls callback functions :return: id of the created trace .. py:method:: remove_trace(idGraph, idTrace, updateChildren=True) Remove the trace from the graph :param idGraph: id of the graph :param idTrace: id of the trace to remove :param updateChildren: Automatically calls callback functions .. py:method:: get_first_graph() Get id of the first graph :return: id of the first graph .. py:method:: get_graph(idGraph) Get graph object at idgraph :param idGraph: id of the graph to get :return: :class:`~Graph` .. py:method:: get_all_graphs_ids() Get all ids of the graphs :return: list of id graphs .. py:method:: get_all_graphs() Get all graphs. Return dict {id: :class:`~Graph`} .. py:method:: add_graph(updateChildren=True) Add a new graph :return: id of the created graph .. py:method:: remove_graph(idGraph) Delete a graph :param idGraph: id of the graph to delete .. py:method:: add_update_method(childObject) Add a callback each time a graph is modified. :param childObject: method without arguments .. py:method:: export_str() Export all the graphs in text :return: str .. py:method:: merge(otherGraphs) .. py:method:: reset() .. py:method:: is_empty() .. py:data:: griddata_found :value: True .. py:class:: Plot3D_Generic(x_label='', y_label='', z_label='', legend='', x_lim=None, y_lim=None, z_lim=None) .. py:method:: get_lim(axis) .. py:method:: get_label(axis) .. py:method:: get_legend() .. py:class:: GridPlot_Generic(X, Y, Z, **kwargs) Bases: :py:obj:`Plot3D_Generic` .. py:method:: get_plot_data() .. py:class:: ContourPlot(*args, **kwargs) Bases: :py:obj:`GridPlot_Generic` .. py:method:: get_levels() .. py:method:: get_number_of_contours() .. py:class:: FilledContourPlot(*args, **kwargs) Bases: :py:obj:`ContourPlot` .. py:class:: SurfPlot(X, Y, Z, **kwargs) Bases: :py:obj:`GridPlot_Generic` .. py:class:: MeshPlot(X, Y, Z, **kwargs) Bases: :py:obj:`GridPlot_Generic` .. py:class:: ScatterPlot3(x, y, z, **kwargs) Bases: :py:obj:`Plot3D_Generic` .. py:method:: get_plot_data() .. py:method:: get_color() .. py:function:: convert_to_gridplot(x, y, z, x_interval=None, y_interval=None, n_x=20, n_y=20) Convert set of points x, y, z to a grid :param x: :param y: :param z: :param x_interval: [Min, max] of the grid. If none, use min and max values :param y_interval: [Min, max] of the grid. If none, use min and max values :param n_x: number of points in x direction :param n_y: number of points in y direction :return: X, Y, Z as grid .. py:class:: HowToPlotGraph(attribute_x, attribute_y, kwargs_graph=None, check_if_plot_elem=None, meta=None) .. py:method:: __str__() Return str(self). .. py:class:: LinkDataGraph .. py:method:: add_collection(theCollection, kwargs=None) Add a collection (that will be a future trace) :param theCollection: :param kwargs: kwargs associated with the collection (e.g., color, symbol style, etc.) :return: unique id associated with the collection .. py:method:: remove_collection(collectionId) Remove collection from the graphs :param collectionId: ID of the collection :return: .. py:method:: set_shadow_collection(master_collectionId, shadow_collection) Link a collection to an other :param master_collectionId: ID of the collection that is displayed in the graph :param shadow_collection: collection to link to the master. :return: .. py:method:: get_graphs() .. py:method:: get_howToPlotGraph(idGraph) .. py:method:: add_graph(howToPlotGraph) Add new graph to be plotted. :param howToPlotGraph: :class:`HowToPlotGraph` :return: .. py:method:: get_idCollections() Get all ids of the plotted collections .. py:method:: get_idGraphs() Get all ids of the graphs .. py:method:: get_idTraces(idGraph) Get all ids of the traces of graph $idGraph .. py:method:: get_idCollection_from_graph(idGraph, idTrace) Get id of collection plotted in graph $idGraph and trace $idTrace .. py:method:: get_collection(idCollection, getShadow=True) .. py:method:: get_kwargs_collection(idCollection) .. py:method:: get_x_y_to_plot(theCollection, howToPlotGraph) :staticmethod: Extract X-Y infos from collection and howtoplotGraph .. py:method:: get_meta_to_plot(theCollection, howToPlotGraph) :staticmethod: Get Z info from collection and HowToPlotGraph .. py:method:: update_graphs() Update the graphs: update graphs, traces, and X-Y data .. py:method:: get_collection_from_graph(idGraph, idTrace, getShadow=True) -> optimeed.core.ListDataStruct_Interface From indices in the graph, get corresponding collection .. py:method:: get_clicked_item(idGraph, idTrace, idPoint, getShadow=True) Get the data hidden behind the clicked point :param idGraph: ID of the graph :param idTrace: ID of the trace :param idPoint: ID of the point :param getShadow: If true, will return the data from the collection linked to the collection that is plotted :return: Object in collection .. py:method:: get_clicked_items(idGraph, idTrace, idPoint_list, getShadow=True) Same as get_clicked_item, but using a list of points .. py:method:: delete_clicked_item(idGraph, idTrace, idPoint) Remove item from the collection .. py:method:: delete_clicked_items(idGraph, idTrace, idPoints) Same, but for a list of points .. py:method:: get_graph_and_trace_from_idCollection(idCollection) Reverse search: from a collection, get all associated graphs .. py:method:: get_idcollection_from_collection(theCollection) Reverse search: from a collection, find its id .. py:method:: get_idPoints_from_indices_in_collection(idGraph, idTrace, indices_in_collection) From indices in a collection, find the associated idPoints of the graph .. py:method:: get_collections() .. py:method:: set_meta_from_shadow() Use this method if 'howToPlot' must use shadow collection .. py:class:: Base_Option(name, based_value, choices=None) .. py:method:: get_value() .. py:method:: get_name() .. py:method:: set_value(value) .. py:method:: get_choices() .. py:class:: Option_bool(name, based_value, choices=None) Bases: :py:obj:`Base_Option` .. py:attribute:: name :type: str .. py:attribute:: value :type: bool .. py:method:: set_value(value) .. py:method:: get_choices() .. py:class:: Option_str(name, based_value, choices=None) Bases: :py:obj:`Base_Option` .. py:attribute:: name :type: str .. py:attribute:: value :type: str .. py:method:: set_value(value) .. py:class:: Option_int(name, based_value, choices=None) Bases: :py:obj:`Base_Option` .. py:attribute:: name :type: str .. py:attribute:: value :type: int .. py:method:: set_value(value) .. py:class:: Option_float(name, based_value, choices=None) Bases: :py:obj:`Base_Option` .. py:attribute:: name :type: str .. py:attribute:: value :type: float .. py:method:: set_value(value) .. py:class:: Option_dict(name, based_value, choices=None) Bases: :py:obj:`Base_Option` .. py:attribute:: name :type: str .. py:attribute:: value :type: dict .. py:method:: set_value(value) .. py:class:: Option_class .. py:attribute:: options_bool :type: Dict[int, Option_bool] .. py:attribute:: options_str :type: Dict[int, Option_str] .. py:attribute:: options_int :type: Dict[int, Option_int] .. py:attribute:: options_float :type: Dict[int, Option_float] .. py:attribute:: options_dict :type: Dict[int, Option_dict] .. py:method:: get_option_attributes() :staticmethod: .. py:method:: add_option(idOption, theOption) .. py:method:: get_option_name(idOption) .. py:method:: get_option_value(idOption) .. py:method:: set_option(idOption, value) .. py:method:: _pack_options() .. py:method:: __str__() Return str(self). .. py:data:: has_scipy :value: True .. py:class:: fast_LUT_interpolation(independent_variables, dependent_variables) Class designed for fast interpolation in look-up table when successive searchs are called often. Otherwise use griddata .. py:method:: interp_tri(xyz) :staticmethod: .. py:method:: interpolate(point, fill_value=np.nan) 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 .. py:function:: interpolate_table(x0, x_values, y_values) From sorted table (x,y) find y0 corresponding to x0 (linear interpolation) .. py:function:: derivate(t, y) .. py:function:: linspace(start, stop, npoints) .. py:function:: reconstitute_signal(amplitudes, phases, numberOfPeriods=1, x_points=None, n_points=50) Reconstitute the signal from fft. Number of periods of the signal must be specified if different of 1 .. py:function:: my_fft(y) Real FFT of signal Bx, with real amplitude of harmonics. Input signal must be within a period. .. py:function:: cart2pol(x, y) .. py:function:: pol2cart(rho, phi) .. py:function:: partition(array, begin, end) .. py:function:: quicksort(array) .. py:function:: dist(p, q) Return the Euclidean distance between points p and q. :param p: [x, y] :param q: [x, y] :return: distance (float) .. py:function:: sparse_subset(points, r) 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) .. py:function:: integrate(x, y) Performs Integral(x[0] to x[-1]) of y dx :param x: x axis coordinates (list) :param y: y axis coordinates (list) :return: integral value .. py:function:: my_fourier(x, y, n, L) Fourier analys :param x: x axis coordinates :param y: y axis coordinates :param n: number of considered harmonic :param L: half-period length :return: a and b coefficients (y = a*cos(x) + b*sin(y)) .. py:function:: get_ellipse_axes(a, b, dphi) 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 .. py:function:: convert_color(color) Convert a color to a tuple if color is a char, otherwise return the tuple. :param color: (r,g,b) or char. :return: .. py:function:: convert_color_with_alpha(color, alpha=255) Same as meth:`convert_color` but with transparency .. py:function:: rgetattr(obj, attr) getattr, but recursively. Works with list. .. py:function:: rsetattr(obj, attr, val) setattr, but recursively. Works with list (i.e. theObj.myList[0].var_x) .. py:function:: printIfShown(theStr, show_type=SHOW_DEBUG, isToPrint=True, appendTypeName=True, end='\n') .. py:data:: SHOW_ERROR :value: 2 .. py:data:: SHOW_WARNING :value: 0 .. py:data:: MODULE_TAG :value: '__module__' .. py:data:: CLASS_TAG :value: '__class__' .. py:data:: EXCLUDED_TAGS .. py:function:: getExecPath() .. py:class:: SaveableObject 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. .. py:method:: get_additional_attributes_to_save() Return list of attributes corresponding to object, whose type cannot be determined statically (e.g. topology change) .. py:method:: get_additional_attributes_to_save_list() Same behavior as get_additional_attributes_to_save, but where the attributes contains list of unknown items .. py:function:: _isclass(theObject) Extends the default isclass method with typing .. py:function:: get_type_class(typ) Get the type of the class. used to compare objects from Typing. .. py:function:: _get_object_class(theObj) .. py:function:: _get_object_module(theObj) .. py:function:: _object_to_FQCN(theobj) Gets module path of object .. py:function:: _find_class(moduleName, className) .. py:function:: json_to_obj(json_dict) 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 .. py:function:: json_to_obj_safe(json_dict, cls) Safe class to create object from dictionary. :param json_dict: dictionary loaded from a json file :param cls: class object to instantiate with dictionary .. py:function:: _instantiates_annotated_object(_json_dict, _cls) .. py:function:: _get_annotations(theObj) Return annotated attributes (theObj being the type of the object) .. py:function:: obj_to_json(theObj) 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 .. py:function:: _get_attributes_to_save(theObj) Return list (attribute, is_first) .. py:function:: get_json_module_tree_from_dict(jsonDict) Return dict containing {CLASS_TAG: "class_name", MODULE_TAG: "module_name", "attribute1":{"class_name": "module_name", ...}} .. py:function:: remove_module_tree_from_string(theStr) Used to compress string by removing __module__ and __class__ entries (used with get_json_module_tree_from_dict) .. py:function:: apply_module_tree_to_dict(nestedTree, nestedObject, raiseError=False) Restore __module__ and __class__ entries from nestedTree in nestedDict .. py:function:: encode_str_json(theStr) .. py:function:: decode_str_json(theStr) .. py:function:: export_to_tikz_groupGraphs(theGraphs: optimeed.core.graphs.Graphs, foldername, additionalPreamble=lambda: '', additionalAxisOptions=lambda graphId: '', additionalTraceOptions=lambda graphId, traceId: '', debug=False) Export the graphs as group :param theGraphs: Graphs to save :param foldername: Foldername to save :param additionalPreamble: method that returns string for custom tikz options :param additionalAxisOptions: method that returns string for custom tikz options :param additionalTraceOptions: method that returns string for custom tikz options :return: .. py:function:: export_to_tikz_contour_plot(list_of_traces3, foldername, filename_data='data') Export the graphs as group :param list_of_traces3: List of 3D traces :param foldername: Foldername to save :param filename_data: filename of the data :return: .. py:function:: printIfShown(theStr, show_type=SHOW_DEBUG, isToPrint=True, appendTypeName=True, end='\n') .. py:data:: SHOW_WARNING :value: 0 .. py:function:: get_path_to_inkscape() .. py:function:: get_inkscape_version() .. py:data:: inkscape_version .. py:function:: inkscape_svg_to_pdf(filename_svg, filename_pdf) .. py:function:: inkscape_svg_to_png(filename_svg, filename_png)