vermouth.utils module¶
Provides several generic utility functions
-
vermouth.utils.
are_all_equal
(iterable)[source]¶ Returns
True
if and only if all elements in iterable are equal; andFalse
otherwise.Parameters: iterable (collections.abc.Iterable) – The container whose elements will be checked. Returns: True
iff all elements in iterable compare equal,False
otherwise.Return type: bool
-
vermouth.utils.
are_different
(left, right)[source]¶ Return True if two values are different from one another.
Values are considered different if they do not share the same type. In case of numerical value, the comparison is done with
numpy.isclose()
to account for rounding. In the context of this test, nan compares equal to itself, which is not the default behavior.The order of mappings (dicts) is assumed to be irrelevant, so two dictionaries are not different if the only difference is the order of the keys.
-
vermouth.utils.
first_alpha
(search_string)[source]¶ Returns the first ASCII letter.
Parameters: string (str) – The string in which to look for the first ASCII letter. Returns: Return type: str Raises: ValueError
– No ASCII letter was found in ‘search_string’.
-
vermouth.utils.
format_atom_string
(node, atomid='', chain='', resname='', resid='', atomname='')[source]¶
-
vermouth.utils.
maxes
(iterable, key=<function <lambda>>)[source]¶ Analogous to
max
, but returns a list of all maxima.>>> all(key(elem) == max(iterable, key=key) for elem in iterable) True
Parameters: - iterable (collections.abc.Iterable) – The iterable for which to find all maxima.
- key (collections.abc.Callable) – This callable will be called on each element of
iterable
to evaluate it to a value. Return values must support>
and==
.
Returns: A list of all maximal values.
Return type: