misc

  • full name: tenpy.tools.misc

  • parent module: tenpy.tools

  • type: module

Exceptions

BetaWarning

Warning category that we emit in new code that still needs to be tested better.

TenpyInconsistencyError

Error class that is raised when a consistency check fails.

TenpyInconsistencyWarning

Warning category that is emitted when a consistency check fails.

Functions

add_with_None_0(a, b)

Return a + b, treating None as zero.

anynan(a)

check whether any entry of a ndarray a is 'NaN'.

argsort(a[, sort])

wrapper around np.argsort to allow sorting ascending/descending and by magnitude.

atleast_2d_pad(a[, pad_item])

Transform a into a 2D array, filling missing places with pad_item.

consistency_check(value, options, ...[, compare])

Perform a consistency check, raising an error if it is violated.

convert_memory_units(value[, unit_from, unit_to])

Convert between different memory units.

find_subclass(base_class, subclass_name)

For a given base class, recursively find the subclass with the given name.

flatten(mapping[, separator])

Obtain a flat dictionary with all key/value pairs of a nested data structure.

get_close(values, target[, default, eps])

Iterate through values and return first entry closer than eps.

get_recursive(nested_data, recursive_key[, ...])

Extract specific value from a nested data structure.

group_by_degeneracy(E, *args[, subset, cutoff])

Find groups of indices for which (energy) values are degenerate.

inverse_permutation(perm)

reverse sorting indices.

lexsort(a[, axis])

wrapper around np.lexsort: allow for trivial case a.shape[0] = 0 without sorting

list_to_dict_list(l)

Given a list l of objects, construct a lookup table.

merge_recursive(*nested_data[, conflict, path])

Merge nested dictionaries nested1 and nested2.

pad(a[, w_l, v_l, w_r, v_r, axis])

Pad an array along a given axis.

set_recursive(nested_data, recursive_key, value)

Same as get_recursive(), but set the data entry to value.

setup_logging([output_filename, filename, ...])

Configure the logging module.

to_array(a[, shape, dtype, allow_incommensurate])

Convert a to an numpy array and tile to matching dimension/shape.

to_iterable(a)

If a is a not iterable or a string, return [a], else return a.

to_iterable_of_len(a, L)

If a is a non-string iterable of length L, return a, otherwise return [a]*L.

transpose_list_list(D[, pad])

Returns a list of lists T, such that T[i][j] = D[j][i].

update_recursive(nested_data, update_data[, ...])

Wrapper around set_recursive() to allow updating multiple values at once.

zero_if_close(a[, tol])

set real and/or imaginary part to 0 if their absolute value is smaller than tol.

Module description

Miscellaneous tools, somewhat random mix yet often helpful.