Various tools.
Class Infolder Contextmanager to do some work in a folder of choice and change dir back in the end.
Class StringList A microtool to join a list of strings using property as_string.
Class InfolderGoneWithTheWind with InfolderGoneWithTheWind(): ... executes the block in a
Class StrList A list of str with search/find functionality.
Class AlgorithmList Not in use. Not necessary when the algorithm dict is an OrderedDict anyway.
Function print_done prints a message with time stamp
Function equals_approximately Undocumented
Function less return a < b, while comparing nan results in False without warning
Function diff_attr return list of [name, val1, val2] triplets for attributes with different values.
Function prepend_to_file "prepend lines the tex-command filename
Function replace_in_file "replace a string in the file with another string
Function truncate_latex_command_file truncate file but keep in good latex shape
Function strip_pathname remove ../ and ./ and leading/trailing blanks and path separators from input string name and replace any remaining path separator with '/'
Function strip_pathname1 remove ../ and ./ and leading/trailing blanks and path separators from input string name, replace any remaining path separator with '/', and keep only the last part of the path
Function strip_pathname2 No summary
Function str_to_latex do replacements in string such that it most likely compiles with latex
Function number_of_digits returns the number of non-zero digits of a number, e.g. two for 1200 or three for 2.03.
Function num2str returns the shortest string representation with either significant_digits digits shown or its true value, whichever is shorter.
Function number_to_latex usage as number_to_latex(num2str(1.023e-12)) == "'-1.0\times10^{-12}'"
Function number_to_html usage as number_to_html(num2str(1.023e-12)) == "'-1.0 x 10<sup>-12</sup>'"
Function legend Undocumented
Function check_output Run command with arguments and return its output as a byte string. Backported from Python 2.7 as it's implemented as pure python on stdlib.
Function git Run a git command and return its output.
Function get_version_label No summary
Function path_in_package return the absolute path prepended to subpath in this module.
def print_done(message=' done'):
prints a message with time stamp
def equals_approximately(a, b, eps=1e-12):
Undocumented
def less(a, b):
return a < b, while comparing nan results in False without warning
def diff_attr(m1, m2, exclude=('_',)):

return list of [name, val1, val2] triplets for attributes with different values.

Attributes whose names start with any string from the exclude list are skipped. Furthermore, only attributes present in both m1 and m2 are compared.

This function was introduced to compare the genericsettings module with its state directly after import. It should be applicable any other two class instances as well.

Details: to "find" the attributes, m1.__dict__ is iterated over.

def prepend_to_file(filename, lines, maxlines=1000, warn_message=None):
"prepend lines the tex-command filename
def replace_in_file(filename, old_text, new_text):
"replace a string in the file with another string
def truncate_latex_command_file(filename, keeplines=200):
truncate file but keep in good latex shape
def strip_pathname(name):
remove ../ and ./ and leading/trailing blanks and path separators from input string name and replace any remaining path separator with '/'
def strip_pathname1(name):
remove ../ and ./ and leading/trailing blanks and path separators from input string name, replace any remaining path separator with '/', and keep only the last part of the path
def strip_pathname2(name):
remove ../ and ./ and leading/trailing blanks and path separators from input string name, replace any remaining path separator with '/', and keep only the last two parts of the path, or only the last
def str_to_latex(string):
do replacements in string such that it most likely compiles with latex
def number_of_digits(val, precision=1e-13):
returns the number of non-zero digits of a number, e.g. two for 1200 or three for 2.03.
def num2str(val, significant_digits=2, force_rounding=False, max_predecimal_digits=5, max_postdecimal_leading_zeros=1, remove_trailing_zeros=True):

returns the shortest string representation with either significant_digits digits shown or its true value, whichever is shorter.

force_rounding shows no more than the desired number of significant digits, which means, e.g., 12345 becomes 12000.

remove_trailing_zeros removes zeros, if and only if the value is exactly.

>>> from cocopp import toolsdivers as td
>>> print([td.num2str(val) for val in [12345, 1234.5, 123.45, 12.345, 1.2345, .12345, .012345, .0012345]])
['12345', '1234', '123', '12', '1.2', '0.12', '0.012', '1.2e-3']
def number_to_latex(number_as_string):
usage as number_to_latex(num2str(1.023e-12)) == "'-1.0\times10^{-12}'"
def number_to_html(number_as_string):
usage as number_to_html(num2str(1.023e-12)) == "'-1.0 x 10<sup>-12</sup>'"
def legend(*args, **kwargs):
Undocumented
def check_output(*popenargs, **kwargs):

Run command with arguments and return its output as a byte string. Backported from Python 2.7 as it's implemented as pure python on stdlib.

WARNING: This method is also defined in ../../code-experiments/tools/cocoutils.py. If you change something you have to change it in both files.

def git(args):

Run a git command and return its output.

All errors are deemed fatal and the system will quit.

WARNING: This method is also defined in ../../code-experiments/tools/cocoutils.py. If you change something you have to change it in both files.

def get_version_label(algorithmID=None):
Returns a string with the COCO version of the installed postprocessing, potentially adding the hash of the hypervolume reference values from the actual experiments (in the bbob-biobj setting). If algorithmID==None, the set of different hypervolume reference values from all algorithms, read in by the postprocessing, are returned in the string. If more than one reference value is present in the data, the string displays also a warning.
def path_in_package(sub_path=''):
return the absolute path prepended to subpath in this module.
API Documentation for cocopp, generated by pydoctor at 2020-01-21 16:27:37.