@@ -1965,6 +1965,40 @@ def test___waveform___pickle___references_public_modules() -> None:
19651965 assert b"nitypes.waveform._timing" not in value_bytes
19661966
19671967
1968+ @pytest .mark .parametrize (
1969+ "pickled_value, expected" ,
1970+ [
1971+ # nitypes 1.0.0
1972+ pytest .param (
1973+ b"\x80 \x04 \x95 \x08 \x02 \x00 \x00 \x00 \x00 \x00 \x00 \x8c \x08 builtins\x94 \x8c \x07 getattr\x94 \x93 \x94 \x8c \x10 nitypes.waveform\x94 \x8c \x0f DigitalWaveform\x94 \x93 \x94 \x8c \t _unpickle\x94 \x86 \x94 R\x94 K\x03 K\x01 \x8c \x05 numpy\x94 \x8c \x05 dtype\x94 \x93 \x94 \x8c \x02 b1\x94 \x89 \x88 \x87 \x94 R\x94 (K\x03 \x8c \x01 |\x94 NNNJ\xff \xff \xff \xff J\xff \xff \xff \xff K\x00 t\x94 b\x87 \x94 }\x94 (\x8c \x04 data\x94 \x8c \x16 numpy._core.multiarray\x94 \x8c \x0c _reconstruct\x94 \x93 \x94 h\t \x8c \x07 ndarray\x94 \x93 \x94 K\x00 \x85 \x94 C\x01 b\x94 \x87 \x94 R\x94 (K\x01 K\x03 K\x01 \x86 \x94 h\x0e \x89 C\x03 \x01 \x01 \x01 \x94 t\x94 b\x8c \x13 extended_properties\x94 h\x03 \x8c \x1a ExtendedPropertyDictionary\x94 \x93 \x94 )\x81 \x94 N}\x94 \x8c \x0b _properties\x94 }\x94 (\x8c \x0e NI_ChannelName\x94 \x8c \x08 Dev1/ai0\x94 \x8c \x12 NI_UnitDescription\x94 \x8c \x05 Volts\x94 us\x86 \x94 b\x8c \x18 copy_extended_properties\x94 \x89 \x8c \x06 timing\x94 h\x02 h\x03 \x8c \x06 Timing\x94 \x93 \x94 h\x06 \x86 \x94 R\x94 (h\x03 \x8c \x12 SampleIntervalMode\x94 \x93 \x94 K\x01 \x85 \x94 R\x94 NN\x8c \x08 datetime\x94 \x8c \t timedelta\x94 \x93 \x94 K\x00 K\x00 M\xe8 \x03 \x87 \x94 R\x94 Nt\x94 }\x94 \x86 \x94 R\x94 u\x86 \x94 R\x94 ." ,
1974+ DigitalWaveform (
1975+ data = np .array ([1 , 2 , 3 ], _np_bool ),
1976+ extended_properties = {"NI_ChannelName" : "Dev1/ai0" , "NI_UnitDescription" : "Volts" },
1977+ timing = Timing .create_with_regular_interval (dt .timedelta (milliseconds = 1 )),
1978+ ),
1979+ marks = pytest .mark .xfail (
1980+ raises = AttributeError ,
1981+ reason = "https://github.com/ni/nitypes-python/issues/234 - ExtendedPropertyDictionary._on_key_changed breaks pickle compatibility" ,
1982+ ),
1983+ ),
1984+ # nitypes 1.0.1
1985+ (
1986+ b"\x80 \x04 \x95 \xf4 \x01 \x00 \x00 \x00 \x00 \x00 \x00 \x8c \x08 builtins\x94 \x8c \x07 getattr\x94 \x93 \x94 \x8c \x10 nitypes.waveform\x94 \x8c \x0f DigitalWaveform\x94 \x93 \x94 \x8c \t _unpickle\x94 \x86 \x94 R\x94 K\x03 K\x01 \x8c \x05 numpy\x94 \x8c \x05 dtype\x94 \x93 \x94 \x8c \x02 b1\x94 \x89 \x88 \x87 \x94 R\x94 (K\x03 \x8c \x01 |\x94 NNNJ\xff \xff \xff \xff J\xff \xff \xff \xff K\x00 t\x94 b\x87 \x94 }\x94 (\x8c \x04 data\x94 \x8c \x16 numpy._core.multiarray\x94 \x8c \x0c _reconstruct\x94 \x93 \x94 h\t \x8c \x07 ndarray\x94 \x93 \x94 K\x00 \x85 \x94 C\x01 b\x94 \x87 \x94 R\x94 (K\x01 K\x03 K\x01 \x86 \x94 h\x0e \x89 C\x03 \x01 \x01 \x01 \x94 t\x94 b\x8c \x13 extended_properties\x94 h\x03 \x8c \x1a ExtendedPropertyDictionary\x94 \x93 \x94 }\x94 (\x8c \x0e NI_ChannelName\x94 \x8c \x08 Dev1/ai0\x94 \x8c \x12 NI_UnitDescription\x94 \x8c \x05 Volts\x94 u\x85 \x94 R\x94 \x8c \x18 copy_extended_properties\x94 \x89 \x8c \x06 timing\x94 h\x02 h\x03 \x8c \x06 Timing\x94 \x93 \x94 h\x06 \x86 \x94 R\x94 (h\x03 \x8c \x12 SampleIntervalMode\x94 \x93 \x94 K\x01 \x85 \x94 R\x94 NN\x8c \x08 datetime\x94 \x8c \t timedelta\x94 \x93 \x94 K\x00 K\x00 M\xe8 \x03 \x87 \x94 R\x94 Nt\x94 }\x94 \x86 \x94 R\x94 u\x86 \x94 R\x94 ." ,
1987+ DigitalWaveform (
1988+ data = np .array ([1 , 2 , 3 ], _np_bool ),
1989+ extended_properties = {"NI_ChannelName" : "Dev1/ai0" , "NI_UnitDescription" : "Volts" },
1990+ timing = Timing .create_with_regular_interval (dt .timedelta (milliseconds = 1 )),
1991+ ),
1992+ ),
1993+ ],
1994+ )
1995+ def test___pickled_value___unpickle___is_compatible (
1996+ pickled_value : bytes , expected : DigitalWaveform [Any ]
1997+ ) -> None :
1998+ new_value = pickle .loads (pickled_value )
1999+ assert new_value == expected
2000+
2001+
19682002def test___waveform_with_extended_properties___pickle_unpickle___valid_on_key_changed () -> None :
19692003 value = DigitalWaveform (
19702004 data = np .array ([1 , 2 , 3 ], _np_bool ),
0 commit comments