``tools`` ============================= .. py:module:: optimeed.core.tools Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: optimeed.core.tools.text_format Functions ~~~~~~~~~ .. autoapisummary:: optimeed.core.tools.software_version optimeed.core.tools.find_and_replace optimeed.core.tools.create_unique_dirname optimeed.core.tools.applyEquation optimeed.core.tools.arithmeticEval optimeed.core.tools.isNonePrintMessage optimeed.core.tools.getPath_workspace optimeed.core.tools.setPath_workspace optimeed.core.tools.getLineInfo optimeed.core.tools.printIfShown optimeed.core.tools.universalPath optimeed.core.tools.add_suffix_to_path optimeed.core.tools.get_object_attrs optimeed.core.tools.rsetattr optimeed.core.tools.rgetattr optimeed.core.tools.indentParagraph optimeed.core.tools.truncate optimeed.core.tools.get_recursive_attrs optimeed.core.tools.str_all_attr optimeed.core.tools.get_2D_pareto optimeed.core.tools.get_ND_pareto optimeed.core.tools.delete_indices_from_list optimeed.core.tools.merge_two_dicts optimeed.core.tools.deep_sizeof optimeed.core.tools.order_lists Attributes ~~~~~~~~~~ .. autoapisummary:: optimeed.core.tools._workspace_path .. 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)