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
arrayargument must be passed toquop_mpi.Ansatz.set_observables()in a FunctionDict .- Parameters:
- partition_tablelist[int]
1-D array describing the global partitioning scheme,
quop_mpi.Ansatzattribute- MPI_COMMIntracomm
MPI communicator,
quop_mpi.Ansatzattribute- arrayUnion[list[float], ndarray[float]]
a 1-D real array containing system size observable values
- Returns:
- ndarray[float64]
local_iobservable values with global index offsetlocal_i_offset(seequop_mpi.Ansatz())
- quop_mpi.observable.csv(partition_table: list[int], MPI_COMM: Intracomm, *args, **kwargs) np.ndarray[np.float64]
Load observables from a
*.csvusing pandas.An Observables Function. The
filenameargument must be passed toquop_mpi.Ansatz.set_observables()in a FunctionDict. Additional keyword arguments in theFunctionDictare passed to the pandas.read_csv method.- Parameters:
- partition_tablelist[int]
1-D array describing the global partitioning scheme,
quop_mpi.Ansatzattribute- MPI_COMMIntracomm
MPI communicator,
quop_mpi.Ansatzattribute- filenamestr
path to a
*csvfile
- Returns:
- ndarray[float64]
local_iobservable values with global index offsetlocal_i_offset(seequop_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
*.h5file using HDF5 for Python.An Observables Function. The
filenameanddataset_namearguments must be passed toquop_mpi.Ansatz.set_observables()in a FunctionDict. Additional positional and keyword arguments in theFunctionDictare passed to the h5py.File method.- Parameters:
- partition_tablelist[int]
1-D array describing the global partitioning scheme,
quop_mpi.Ansatzattribute- MPI_COMMIntracomm
MPI communicator,
quop_mpi.Ansatzattribute- filenamestr
path to a
*.h5file- dataset_namestr
path to the dataset in
filenamecontaining an ndarray[float64] of system size observables.
- Returns:
- ndarray[float64]
local_iobservable values with global index offsetlocal_i_offset(seequop_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
functionargument must be passed to quop_mpi.Ansatz.set_observables()in a FunctionDict. Additional- positional and keyword arguments in the
FunctionDictare passed to function.
- Parameters:
- partition_tablelist[int]
- 1-D array describing the global partitioning scheme,
quop_mpi.Ansatzattribute
- MPI_COMMIntracomm
MPI communicator,
quop_mpi.Ansatzattribute- functionCallable
- Python function returning a 1-D real array of system size
observable values
- Returns:
- ndarray[float64]
local_iobservable values with global index offsetlocal_i_offset(seequop_mpi.Ansatz())
- An Observables Function. The
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
lowandhigharguments can be passed toquop_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.Ansatzattribute- seedint
sets the seed of the random number generator,
quop_mpi.Ansatzattribute- MPI_COMMIntracomm
MPI intracommunicator,
quop_mpi.Ansatzattribute- 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_iobservable values with global index offsetlocal_i_offset(seequop_mpi.Ansatz())