Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test_packages failures #519

Merged
merged 8 commits into from
Jan 17, 2025
3 changes: 3 additions & 0 deletions pygsti/data/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1730,6 +1730,9 @@ def _add_raw_arrays(self, circuit, oli_array, time_array, rep_array,
# so we need to build this up for all existings sequences:
self._add_explicit_repetition_counts()

dtype_info = _np.finfo(rep_array.dtype)
rep_array = rep_array.round(dtype_info.precision)

if not record_zero_counts:
# Go through repArray and remove any zeros, along with
# corresponding elements of oliArray and timeArray
Expand Down
15 changes: 9 additions & 6 deletions test/test_packages/drivers/test_timedep.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,20 @@ def test_time_dependent_datagen(self):
ds = pygsti.data.simulate_data(mdl, circuits, num_samples=100,
sample_error='none', seed=1234, times=[0,0.1,0.2])

self.assertArraysEqual(ds[Circuit([Label('Gi',0)], line_labels=(0,))].time, np.array([0., 0., 0.1, 0.1, 0.2, 0.2]))
self.assertArraysEqual(ds[Circuit([Label('Gi',0)], line_labels=(0,))].reps, np.array([100., 0., 95., 5., 90., 10.]))
self.assertArraysEqual(ds[Circuit([Label('Gi',0)], line_labels=(0,))].outcomes, [('0',), ('1',), ('0',), ('1',), ('0',), ('1',)])
dsr = ds[Circuit([Label('Gi',0)], line_labels=(0,))]
self.assertArraysEqual(dsr.time, np.array([0., 0., 0.1, 0.1, 0.2, 0.2]))
self.assertArraysEqual(dsr.reps, np.array([100., 0., 95., 5., 90., 10.]))
self.assertArraysEqual(dsr.outcomes, [('0',), ('1',), ('0',), ('1',), ('0',), ('1',)])

# sparse data
ds2 = pygsti.data.simulate_data(mdl, circuits, num_samples=100,
sample_error='none', seed=1234, times=[0,0.1,0.2],
record_zero_counts=False)
self.assertArraysEqual(ds2[Circuit([Label('Gi',0)], line_labels=(0,))].time, np.array([0., 0.1, 0.1, 0.2, 0.2]))
self.assertArraysEqual(ds2[Circuit([Label('Gi',0)], line_labels=(0,))].reps, np.array([100., 95., 5., 90., 10.]))
self.assertArraysEqual(ds2[Circuit([Label('Gi',0)], line_labels=(0,))].outcomes, [('0',), ('0',), ('1',), ('0',), ('1',)])
ds2r = ds2[Circuit([Label('Gi',0)], line_labels=(0,))]
self.assertArraysEqual(ds2r.time, np.array([0., 0.1, 0.1, 0.2, 0.2]))
self.assertArraysEqual(ds2r.reps, np.array([100., 95., 5., 90., 10.]))
self.assertArraysEqual(ds2r.outcomes, [('0',), ('0',), ('1',), ('0',), ('1',)])
return

def test_time_dependent_gst_staticdata(self):

Expand Down
Loading