mechanoChemML.src.texify

Module Contents

Classes

Texify Render strings as Latex strings

Functions

groupsort(groups, args) Get unique args from groups and sort in same order as in args
icombinations(iterable, n, unique=False) Get all combinations of p number of non-negative integers that sum up to at most n
findstring(string, strings, types, prefixes, labels, replacements, default=None, regex=False, usetex=True) Check if string in strings dictionary
isnumber(s) Check if object is a float or integer number
scinotation(number, decimals=2, base=10, order=2, zero=True, scilimits=[-1, 1], usetex=True) Put number into scientific notation string
mechanoChemML.src.texify.DELIMITER = __[source]
mechanoChemML.src.texify.groupsort(groups, args)[source]

Get unique args from groups and sort in same order as in args

mechanoChemML.src.texify.icombinations(iterable, n, unique=False)[source]

Get all combinations of p number of non-negative integers that sum up to at most n :param iterable: Number of integers or iterable of length p :type iterable: iterable :param n: Maximum number of elements, or allowed number of elements :type n: int,iterable :param unique: Return unique combinations of integers and q = choose(p+n,n) else q = (p^(n+1)-1)/(p-1) :type unique: bool

Returns:All combinations of iterable with q list of lists of length up to n, or lengths in n
Return type:combinations (list)
mechanoChemML.src.texify.findstring(string, strings, types, prefixes, labels, replacements, default=None, regex=False, usetex=True)[source]

Check if string in strings dictionary :param string: String to be checked if in strings dictionary :type string: str :param strings: Dictionary of string keys with replacement strings values :type strings: dict :param types: Dictionary of variable types that strings may start with, with template values in order to determine how to render strings :type types: dict :param prefixes: Dictionary of prefix types that strings may start with, with template values in order to determine how to render strings :type prefixes: dict :param labels: Dictionary of label prefixes for string templates to render strings :type labels: dict :param default: default return value if string not in strings :type default: str,None :param regex: perform regex processing to find string pattern in strings :type regex: bool

Returns:Returned string based on logic of whether string is in strings
mechanoChemML.src.texify.isnumber(s)[source]

Check if object is a float or integer number :param s: Object to be checked as number :type s: object

Returns:Boolean of whether object s is a number
mechanoChemML.src.texify.scinotation(number, decimals=2, base=10, order=2, zero=True, scilimits=[-1, 1], usetex=True)[source]

Put number into scientific notation string :param number: Number to be processed :type number: str,int,float :param decimals: Number of decimals in base part of number :type decimals: int :param base: Base of scientific notation :type base: int :param order: Max power of number allowed for rounding :type order: int :param zero: Make numbers that equal 0 be the int representation :type zero: bool :param scilimits: Limits on where not to represent with scientific notation :type scilimits: list :param usetex: Render string with Latex :type usetex: bool

Returns:String with scientific notation format for number
class mechanoChemML.src.texify.Texify(texstrings={}, texargs={}, texlabels={}, usetex=True)[source]

Bases: object

Render strings as Latex strings

Parameters:
  • texstrings (dict) – Dictionary of text strings with Latex string values
  • texargs (dict) – Dictionary of arguments and settings used in Latex rendering
  • texlabels (dict) – Dictionary of modifier strings for Latex rendering
  • labels (dict) – Dictionary of label prefixes for string templates for Latex rendering
  • usetex (bool) – Render as Latex strings, or render as text strings
texify(self, string, texstrings={}, texargs={}, texlabels={}, usetex=True)[source]

Render string as Latex string :param string: String to be rendered :type string: str :param texstrings: Dictionary of text strings with Latex string values :type texstrings: dict :param texargs: Dictionary of arguments and settings used in Latex rendering :type texargs: dict :param texlabels: Dictionary of modifier strings for Latex rendering :type texlabels: dict :param usetex: Render as Latex strings, or render as text strings :type usetex: bool

Returns:Latex rendered string