mirror of https://github.com/m-labs/artiq.git
pyon: Correctly deserialize bare NaNs
This also fixes (non-numpy) lists containing NaNs. Previously, accidentally storing a NaN in a dataset would bring down large parts of the system.
This commit is contained in:
parent
08ee91beb2
commit
829fca6112
|
@ -194,6 +194,7 @@ _eval_dict = {
|
||||||
"false": False,
|
"false": False,
|
||||||
"true": True,
|
"true": True,
|
||||||
"slice": slice,
|
"slice": slice,
|
||||||
|
"nan": numpy.nan,
|
||||||
|
|
||||||
"Fraction": Fraction,
|
"Fraction": Fraction,
|
||||||
"OrderedDict": OrderedDict,
|
"OrderedDict": OrderedDict,
|
||||||
|
|
|
@ -26,6 +26,8 @@ class PYON(unittest.TestCase):
|
||||||
with self.subTest(enc=enc):
|
with self.subTest(enc=enc):
|
||||||
self.assertEqual(pyon.decode(enc(_pyon_test_object)),
|
self.assertEqual(pyon.decode(enc(_pyon_test_object)),
|
||||||
_pyon_test_object)
|
_pyon_test_object)
|
||||||
|
# NaNs don't compare equal, so test separately.
|
||||||
|
assert np.isnan(pyon.decode(enc(np.nan)))
|
||||||
|
|
||||||
def test_encdec_array(self):
|
def test_encdec_array(self):
|
||||||
orig = {k: (np.array(v), np.array([v]))
|
orig = {k: (np.array(v), np.array([v]))
|
||||||
|
|
Loading…
Reference in New Issue