Observable

Functions for defining observables (cost functions) used to compute expectation values.

Module Reference

Predefined Observable Functions.

See also: quop_mpi.Ansatz.set_observables().

quop_mpi.observable.array(partition_table: list[int], MPI_COMM: Intracomm, array: list[float] | np.ndarray[float]) np.ndarray[np.float64]

Define observables with a NumPy ndarray.

An Observables Function. The array argument must be passed to quop_mpi.Ansatz.set_observables() in a FunctionDict .

Parameters:
partition_tablelist[int]

1-D array describing the global partitioning scheme, quop_mpi.Ansatz attribute

MPI_COMMIntracomm

MPI communicator, quop_mpi.Ansatz attribute

arrayUnion[list[float], ndarray[float]]

a 1-D real array containing system size observable values

Returns:
ndarray[float64]

local_i observable values with global index offset local_i_offset (see quop_mpi.Ansatz())

quop_mpi.observable.csv(partition_table: list[int], MPI_COMM: Intracomm, *args, **kwargs) np.ndarray[np.float64]

Load observables from a *.csv using pandas.

An Observables Function. The filename argument must be passed to quop_mpi.Ansatz.set_observables() in a FunctionDict. Additional keyword arguments in the FunctionDict are passed to the pandas.read_csv method.

Parameters:
partition_tablelist[int]

1-D array describing the global partitioning scheme, quop_mpi.Ansatz attribute

MPI_COMMIntracomm

MPI communicator, quop_mpi.Ansatz attribute

filenamestr

path to a *csv file

Returns:
ndarray[float64]

local_i observable values with global index offset local_i_offset (see quop_mpi.Ansatz())

quop_mpi.observable.hdf5(partition_table: list[int], MPI_COMM: Intracomm, filename: str, dataset_name: str, **kwargs) np.ndarray[np.float64]

Load observables from a *.h5 file using HDF5 for Python.

An Observables Function. The filename and dataset_name arguments must be passed to quop_mpi.Ansatz.set_observables() in a FunctionDict. Additional positional and keyword arguments in the FunctionDict are passed to the h5py.File method.

Parameters:
partition_tablelist[int]

1-D array describing the global partitioning scheme, quop_mpi.Ansatz attribute

MPI_COMMIntracomm

MPI communicator, quop_mpi.Ansatz attribute

filenamestr

path to a *.h5 file

dataset_namestr

path to the dataset in filename containing an ndarray[float64] of system size observables.

Returns:
ndarray[float64]

local_i observable values with global index offset local_i_offset (see quop_mpi.Ansatz())

quop_mpi.observable.serial(partition_table: list[int], MPI_COMM: Intracomm, function: Callable, *args, **kwargs) np.ndarray[np.float64]

Generate observables using a serial python function.

An Observables Function. The function argument must be passed to

quop_mpi.Ansatz.set_observables() in a FunctionDict. Additional

positional and keyword arguments in the FunctionDict are passed to

function.

Parameters:
partition_tablelist[int]
1-D array describing the global partitioning scheme,

quop_mpi.Ansatz attribute

MPI_COMMIntracomm

MPI communicator, quop_mpi.Ansatz attribute

functionCallable
Python function returning a 1-D real array of system size

observable values

Returns:
ndarray[float64]

local_i observable values with global index offset local_i_offset (see quop_mpi.Ansatz())

Random Observables

Functions for generating random observables, useful for testing.

quop_mpi.observable.rand.uniform(system_size: int, partition_table: list[int], seed: int, MPI_COMM: Intracomm, low: float = 0, high: float = 1) np.ndarray[np.float64]

Generate random observables from a uniform distribution.

An Observables Function. The low and high arguments can be passed to quop_mpi.Ansatz.set_observables() in a FunctionDict.

Parameters:
system_sizeint

the size of the simulated system, class:quop_mpi.Ansatz attribute

partition_tablelist[int]

1-D array describing the global partitioning scheme, quop_mpi.Ansatz attribute

seedint

sets the seed of the random number generator, quop_mpi.Ansatz attribute

MPI_COMMIntracomm

MPI intracommunicator, quop_mpi.Ansatz attribute

lowfloat, optional

lower bound of the generated observable values (inclusive), by default 0

highfloat, optional

upper bound of the genereated observable values (exclusive), by default 1

Returns:
np.ndarray[float64]

local_i observable values with global index offset local_i_offset (see quop_mpi.Ansatz())