Skip to content

Commit 97b1db8

Browse files
committed
guard against None-valued rep_array and walk on eggshells in rounding fix
1 parent a5a4011 commit 97b1db8

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

pygsti/data/dataset.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1730,8 +1730,10 @@ def _add_raw_arrays(self, circuit, oli_array, time_array, rep_array,
17301730
# so we need to build this up for all existings sequences:
17311731
self._add_explicit_repetition_counts()
17321732

1733-
dtype_info = _np.finfo(rep_array.dtype)
1734-
rep_array = rep_array.round(dtype_info.precision)
1733+
if rep_array is not None:
1734+
dtype_info = _np.finfo(rep_array.dtype)
1735+
near_zero = rep_array < 10**(-1.5*dtype_info.precision)
1736+
rep_array[near_zero] = 0
17351737

17361738
if not record_zero_counts:
17371739
# Go through repArray and remove any zeros, along with

test/unit/util.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,11 @@ def __getattr__(self, name):
219219
except AttributeError as err:
220220
if name in self.__ns_props__:
221221
return self.__ns_props__[name](self)
222-
else:
223-
raise err
222+
# else:
223+
# raise err
224+
return None
225+
# ^ necessary to avoid cursed issues that can arise when a call to pyest.main(...)
226+
# ends up triggering a test which needs the Namespace class.
224227

225228
def property(self, fn):
226229
"""Dynamic namespace property"""

0 commit comments

Comments
 (0)