Miscellany utils

Log messages

Show error and log messages.

misc_utils.log_messages.error(msg)
misc_utils.log_messages.log(msg)
misc_utils.log_messages.to_file(fName)
misc_utils.log_messages.warning(msg)

Pickle utils

class misc_utils.pickle_utils.interp1dPicklable(xi, yi, **kwargs)

Bases: object

class wrapper for piecewise linear function

Staircase function

class misc_utils.staircase_function.StairCaseFunction(xi, vi, leftDefaultValue=0.0, rightDefaultValue=0.0)

Bases: object

Function defined as a series of constant values in consecutive intervals

Data structures utils

String manipulation utilities.

misc_utils.data_struct_utils.get_closest_inlist(lst, value)

Return the number in a list that is the closest to the target value.

Parameters:
  • lst – list of numbers
  • value – target value.
misc_utils.data_struct_utils.get_encoding(input_str)

Return the encoding of the the string argument.

misc_utils.data_struct_utils.get_index_closest_inlist(lst, value)

Return the index in a list that matches the closest element to the target value.

Parameters:
  • lst – list of numbers.
  • value – target value.
misc_utils.data_struct_utils.is_ascii(input_str)

Return true if the argument is an ascii string.

misc_utils.data_struct_utils.remove_accents(input_str)

Remove the accents from the string argument.

Parameters:input_str – string to remove accents from.
misc_utils.data_struct_utils.remove_duplicates_list(lst)

Return a list from lst without items duplicated

misc_utils.data_struct_utils.slugify(s)

Simplifies ugly strings into something URL-friendly. >>> print(slugify(“[Some] _ Article’s Title–”)) some-articles-title

misc_utils.data_struct_utils.to_unicode(input_str)

Return a unicode string from the input.

Parameters:input_str – input string.

Unit utils

misc_utils.units_utils.convert_inches(n)

Return (feet,inches,inches’ fraction) equivalent to number n of inches given as parameter, where n is a real number.

misc_utils.units_utils.feet_and_inches(n)
misc_utils.units_utils.roundLst(lst, decpl)

return a list with the values of ‘lst’ rounded to ‘decpl’ decimal places

misc_utils.units_utils.show_inches(inches, fractions)

Pretty printing of (inches,fractions) given as parameter