OptimizationFlag

Inheritance Diagram

Inheritance diagram of tenpy.tools.optimization.OptimizationFlag

Methods

OptimizationFlag.from_bytes(bytes, byteorder, *)

Like int.from_bytes, which has a docstring which sphinx cant parse

OptimizationFlag.to_bytes([length, ...])

Like int.to_bytes, which has a docstring which sphinx cant parse

OptimizationFlag.__init__(*args, **kwds)

OptimizationFlag.as_integer_ratio()

Return integer ratio.

OptimizationFlag.bit_count()

Number of ones in the binary representation of the absolute value of self.

OptimizationFlag.bit_length()

Number of bits necessary to represent self in binary.

OptimizationFlag.conjugate

Returns self, the complex conjugate of any int.

Class Attributes and Properties

OptimizationFlag.none

OptimizationFlag.default

OptimizationFlag.safe

OptimizationFlag.skip_arg_checks

OptimizationFlag.denominator

the denominator of a rational number in lowest terms

OptimizationFlag.imag

the imaginary part of a complex number

OptimizationFlag.numerator

the numerator of a rational number in lowest terms

OptimizationFlag.real

the real part of a complex number

class tenpy.tools.optimization.OptimizationFlag(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

Options for the global ‘optimization level’ used for dynamical optimizations.

Whether we optimize dynamically is decided by comparison of the global “optimization level” with one of the following flags. A higher level includes all the previous optimizations.

Level

Flag

Description

0

none

Don’t do any optimizations, i.e., run many sanity checks. Used for testing.

1

default

Skip really unnecessary sanity checks, but also don’t try any optional optimizations if they might give an overhead.

2

safe

Activate safe optimizations in algorithms, even if they might give a small overhead. Example: Try to compress the MPO representing the hamiltonian.

3

skip_arg_checks

Unsafe! Skip (some) class sanity tests and (function) argument checks.

Warning

When unsafe optimizations are enabled, errors will not be detected that easily, debugging is much harder, and you might even get segmentation faults in the compiled parts. Use this kind of optimization only for code which you successfully ran before with (very) similar parameters and disabled optimizations! Enable this optimization only during the parts of the code where it is really necessary. Check whether it actually helps - if it doesn’t, keep the optimization disabled!

classmethod from_bytes(bytes, byteorder, *, signed=False)[source]

Like int.from_bytes, which has a docstring which sphinx cant parse

to_bytes(length=1, byteorder='big', *, signed=False)[source]

Like int.to_bytes, which has a docstring which sphinx cant parse

as_integer_ratio()

Return integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number