quchip.results.trajectories

Native trajectories with captured model context and lazy analysis views.

Classes

ClickRecords(times, channels, weights, ...)

Jump events of a stochastic solve, in one layout on both backends.

MeasurementRecords(values, channels, edges, ...)

Diffusive measurement currents of a stochastic solve, in one layout on both backends.

TrajectoryResult(native, problem, *[, ...])

Keep a native stochastic result with its storage and weights unchanged.

class quchip.results.trajectories.MeasurementRecords(values, channels, edges, sampling, efficiencies, phases, heterodyne)[source]

Bases: object

Diffusive measurement currents of a stochastic solve, in one layout on both backends.

A monitored channel with collapse operator L, efficiency η and phase φ records the current 2 Re⟨c⟩ + ξ on each interval, in 1/sqrt(ns), with c = √η e^(−iφ) L. Here L includes the square root of its rate. The homodyne noise ξ has variance 1/Δt. A QuTiP heterodyne solve records the quadratures 2 Re⟨c⟩ + ξ_X and 2 Im⟨c⟩ + ξ_Y, and each noise has variance 2/Δt. The values keep this native normalization and the native sampling of the signal on each interval.

Variables:
  • values (array_like) – Current of each run, channel and interval, with shape (runs, channels, intervals). A QuTiP heterodyne solve adds a quadrature axis of length 2 before the intervals.

  • channels (tuple of str or None) – Channel of each row, as TrajectoryResult.monitor_labels gives them. None when a traced efficiency leaves the native order unknown.

  • edges (array_like, shape (intervals + 1,)) – Interval edges in ns: the save times of the solve.

  • sampling ({"start", "middle", "end", "mean"}) – Signal sample of each interval. QuTiP takes the signal at the start or the end of an interval, or the mean of both, as its option store_measurement selects, and adds the noise increment divided by Δt. Dynamiqs divides the increment of the integrated record by Δt, so the signal is its mean over the interval.

  • efficiencies (tuple) – Efficiency η of each row.

  • phases (tuple) – Phase φ of each row, in rad, relative to the integration frame.

  • heterodyne (bool) – Whether values has a quadrature axis.

values: Any
channels: tuple[str, ...] | None
edges: Any
sampling: str
efficiencies: tuple[Any, ...]
phases: tuple[Any, ...]
heterodyne: bool
class quchip.results.trajectories.ClickRecords(times, channels, weights, no_click_weight, full)[source]

Bases: object

Jump events of a stochastic solve, in one layout on both backends.

An ensemble mean over runs is the weighted sum Σ_r w_r x_r, plus the no-click run with its weight no_click_weight when the native sampling solves that run apart: QuTiP improved_sampling and the dynamiqs Event(smart_sampling=True). The weights then sum to 1 − no_click_weight.

Variables:
  • times (tuple of array_like) – Click times of each run in ns, in increasing order.

  • channels (tuple of tuple of str) – Channel of each click, from TrajectoryResult.channel_labels.

  • weights (array_like, shape (runs,)) – Sampling weight of each run.

  • no_click_weight (float) – Weight of the no-click run that the native sampling solves apart, or 0.

  • full (array_like of bool, shape (runs,)) – Whether a run filled its dynamiqs nmaxclick buffer. Its evolution may stop before the end of the solve. QuTiP has no buffer.

times: tuple[Any, ...]
channels: tuple[tuple[str, ...], ...]
weights: Any
no_click_weight: float
full: Any
counts(channel=None)[source]

Return the number of clicks of each run, shape (runs,).

Parameters:

channel (str or None, default=None) – Count only this channel. None counts every channel.

class quchip.results.trajectories.TrajectoryResult(native, problem, *, label_targets=None)[source]

Bases: SimulationResult

Keep a native stochastic result with its storage and weights unchanged.

Parameters:
  • native (object) – QuTiP or Dynamiqs stochastic result, including seeds/keys and records.

  • problem (SolveProblem) – Captured model, observables, channel order, and integration frame.

  • label_targets (LabelTargets or None, optional) – Snapshot of the solve’s chip that prepares label targets.

Variables:
  • native (object) – Unmodified native result, with native record conventions and event padding.

  • times (array_like, shape (T,)) – Requested save times in ns.

  • channel_labels (tuple of str) – Unique resolved channel keys in native jump-operator order.

  • monitor_labels (tuple of str or None) – Native record channel order for an explicit selection, or None when unknown.

average()[source]

Return native ensemble averages, including native trajectory weights.

run(index)[source]

Return the analysis of one kept conditional trajectory.

Parameters:

index (int) – Zero-based trajectory index of a run that native storage keeps.

expect(key, index=None)[source]

Return a named native ensemble expectation, shape (T,).

Parameters:
  • key (object or str) – Captured observable key.

  • index (int or None, default None) – Entry in a list-valued observable. Trajectory selection uses run().

records()[source]

Return the diffusive measurement currents of every kept run.

QuTiP keeps them with the native option store_measurement. result.native keeps the unmodified native fields.

clicks()[source]

Return the jump events of every kept run, with the sampling weight of each run.

run_expect(key, index=None)[source]

Return a named expectation of every kept run, shape (runs, T).

Row i equals run(i).expect(key, index). The native sampling weights do not enter; expect() gives the weighted ensemble mean.

Parameters:
  • key (object or str) – Captured observable key.

  • index (int or None, default None) – Entry in a list-valued observable.