quantax.utils.DataTracer#

class quantax.utils.DataTracer#

Keeps track of a scalar time series, typically an observable (e.g. energy) recorded once per optimization or time-evolution step.

The data points are stored in a growing list and exposed as numpy arrays through data and time.

__array__() NDArray[floating]#

Return data as a numpy array.

__getitem__(idx) NDArray[floating]#

Get data by indexing.

property data: NDArray[floating]#

The data stored in the DataTracer

property time: NDArray[floating]#

The time stored in the DataTracer

append(data: ArrayLike | None, time: ArrayLike | None = None) None#

Append a new data point.

Parameters:
  • data – The data to be appended, expected to be a scalar. None is ignored, so optional quantities can be appended unconditionally.

  • time – The time of the data point, default to be incremental by 1 in each append.

mean() floating#

Mean value of the data

uncertainty() floating | None#

Standard error of the mean, None if fewer than 2 data points are stored.

save(file: str | PathLike[str] | BinaryIO) None#

Save data to file

save_time(file: str | PathLike[str] | BinaryIO) None#

Save time to file

plot(start: int | None = None, end: int | None = None, batch: int = 1, logx: bool = False, logy: bool = False, baseline: ArrayLike | None = None) None#

Plot the data

Parameters:
  • start – Starting index

  • end – Ending index

  • batch – Batch size. The mean value in a whole batch is one data point in the plot

  • logx – Whether to use log scale in x-axis

  • logy – Whether to use log scale in y-axis

  • baseline – Show a dashed line y=baseline