@@ -86,6 +86,30 @@ def success(self) -> bool:
8686 """A collection of test failure information."""
8787
8888
89+ class _DigitalWaveformExtendedProperties (ExtendedPropertyDictionary ):
90+ """Extended properties that invalidate cached line names when NI_LineNames is modified."""
91+
92+ __slots__ = ["_waveform" ]
93+
94+ def __init__ (
95+ self ,
96+ waveform : DigitalWaveform [Any ],
97+ properties : Mapping [str , ExtendedPropertyValue ] | None = None ,
98+ ) -> None :
99+ super ().__init__ (properties )
100+ self ._waveform = waveform
101+
102+ def __setitem__ (self , key : str , value : ExtendedPropertyValue , / ) -> None :
103+ super ().__setitem__ (key , value )
104+ if key == LINE_NAMES :
105+ self ._waveform ._line_names = None
106+
107+ def __delitem__ (self , key : str , / ) -> None :
108+ super ().__delitem__ (key )
109+ if key == LINE_NAMES :
110+ self ._waveform ._line_names = None
111+
112+
89113class DigitalWaveform (Generic [TDigitalState ]):
90114 """A digital waveform, which encapsulates digital data and timing information.
91115
@@ -805,9 +829,9 @@ def __init__(
805829 raise invalid_arg_type ("raw data" , "NumPy ndarray" , data )
806830
807831 if copy_extended_properties or not isinstance (
808- extended_properties , ExtendedPropertyDictionary
832+ extended_properties , _DigitalWaveformExtendedProperties
809833 ):
810- extended_properties = ExtendedPropertyDictionary ( extended_properties )
834+ extended_properties = _DigitalWaveformExtendedProperties ( self , extended_properties )
811835 self ._extended_properties = extended_properties
812836
813837 if timing is None :
@@ -1334,12 +1358,24 @@ def __eq__(self, value: object, /) -> bool:
13341358 and self ._timing == value ._timing
13351359 )
13361360
1361+ def __copy__ (self ) -> Self :
1362+ """Return a shallow copy of self."""
1363+ return self .__class__ (
1364+ self ._sample_count ,
1365+ self .signal_count ,
1366+ self .dtype ,
1367+ data = self .data ,
1368+ extended_properties = self ._extended_properties ,
1369+ copy_extended_properties = False ,
1370+ timing = self ._timing ,
1371+ )
1372+
13371373 def __reduce__ (self ) -> tuple [Any , ...]:
13381374 """Return object state for pickling."""
13391375 ctor_args = (self ._sample_count , self .signal_count , self .dtype )
13401376 ctor_kwargs : dict [str , Any ] = {
13411377 "data" : self .data ,
1342- "extended_properties" : self ._extended_properties ,
1378+ "extended_properties" : ExtendedPropertyDictionary ( self ._extended_properties ) ,
13431379 "copy_extended_properties" : False ,
13441380 "timing" : self ._timing ,
13451381 }
0 commit comments