Supports cache deletion via method_name.clear_cache(self).
Changed in version 2021.2: Can memoize methods on classes that do not allow setting attributes
(e.g. by overwriting __setattr__), e.g. frozen dataclasses.
Adds a cache to the function it decorates. The cache is attached
to container and must be uniquely specified by identifier (i.e.
all functions using the same container and identifier will be using
the same cache). The decorated function may only receive positional
arguments.
Note
This function works well on nested functions, which
do not have stable global identifiers.
Changed in version 2020.3: identifier no longer needs to be a str,
but it needs to be hashable.
Changed in version 2021.2.1: Can now use instances of classes as container that do not allow
setting attributes (e.g. by overwriting __setattr__),
e.g. frozen dataclasses.
Like memoize_method, but additionally uses a function key to
compute the key under which the function result is stored.
Supports cache deletion via method_name.clear_cache(self).
Parameters:
key – A function receiving the same arguments as the decorated function
which computes and returns the cache key.
Added in version 2020.3.
Changed in version 2021.2: Can memoize methods on classes that do not allow setting attributes
(e.g. by overwriting __setattr__), e.g. frozen dataclasses.
Enumerate all non-negative integer tuples summing to at most n,
exhausting the search space by varying the first entry fastest,
and the last entry the slowest.
alignments – A tuple of alignments of each column:
"l", "c", or "r", for left, center, and right
alignment, respectively). Columns which have no alignment specifier
will use the last specified alignment. For example, with
alignments=("l","r"), the third and all following
columns will use right alignment.
conflicting_ok – A flag to dictate the behavior when name is
conflicting with the set of existing names. If True, a conflict
is silently passed. If False, a ValueError is raised on
encountering a conflict.
Create a new view object with shape newshape without copying the data of
a. This function is different from numpy.reshape by raising an
exception when data copy is necessary.
Using a hash algorithm given by the parameter-less constructor
hash_constructor, return a hash object whose internal state
depends on the entries of iterable, but not their order. If hash
is the instance returned by evaluating hash_constructor(), then
the each entry i of the iterable must permit hash.update(i) to
succeed. An example of hash_constructor is hashlib.sha256
from hashlib. hash.digest_size must also be defined.
If hash_constructor is not provided, hash_instance.name is
used to deduce it.
Returns:
the updated hash_instance.
Warning
The construction used in this function is likely not cryptographically
secure. Do not use this function in a security-relevant context.
Generate points on a sphere based on an offset Fibonacci lattice from [2].
Parameters:
optimize – takes the values: None to use the standard Fibonacci
lattice, "minimum" to minimize the nearest neighbor distances in the
lattice and "average" to minimize the average distances in the
lattice.
Convert a string representation of truth to True or False.
True values are ‘y’, ‘yes’, ‘t’, ‘true’, ‘on’, and ‘1’; false values
are ‘n’, ‘no’, ‘f’, ‘false’, ‘off’, and ‘0’. Uppercase versions are
also accepted. If default is None, raises ValueError if val is anything
else. If val is None and default is not None, returns default.
Based on distutils.util.strtobool().
Convert a string to a valid Python identifier, by removing
non-alphanumeric, non-underscore characters, and prepending an underscore
if the string starts with a numeric character.
Return unique elements in seq, removing all duplicates. The internal
order of the elements is preserved. See also
itertools.groupby() (which removes consecutive duplicates).
Return a table joining this and the C{other_table} on C{column}.
The new table has the following columns:
- C{column}, titled the same as in this table.
- the columns of this table, minus C{column}.
- the columns of C{other_table}, minus C{other_column}.
Assumes both tables are sorted ascendingly by the column
by which they are joined.