• full name: tenpy.tools.misc

  • parent module: tenpy.tools

  • type: module


add_with_None_0(a, b)

Return a + b, treating None as zero.

any_nonzero(params, keys[, verbose_msg])

Check for any non-zero or non-equal entries in some parameters.

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.

build_initial_state(size, states, filling[, …])

chi_list(chi_max[, dchi, nsweeps, verbose])


reverse sorting indices.

lexsort(a[, axis])

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


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

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

Pad an array along a given axis.

setup_executable(mod, run_defaults[, …])

Read command line arguments and turn into useable dicts.

to_array(a[, shape])

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


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].

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.