Bug Report
Testing with nidaqmx in ni/nidaqmx-python#828 revealed that AnalogWaveform.scaled_data always copies the data array.
Repro or Code Sample
>>> import numpy as np
>>> x = np.linspace(0.0, 5.0, 10, dtype=np.float64)
>>> y = x[::2]
>>> from nitypes.waveform import AnalogWaveform
>>> w = AnalogWaveform(raw_data=y)
>>> w.raw_data.flags
C_CONTIGUOUS : False
F_CONTIGUOUS : False
OWNDATA : False
WRITEABLE : True
ALIGNED : True
WRITEBACKIFCOPY : False
>>> w.scaled_data.flags
C_CONTIGUOUS : True
F_CONTIGUOUS : True
OWNDATA : True
WRITEABLE : True
ALIGNED : True
WRITEBACKIFCOPY : False
>>> w.raw_data.astype(np.float64).flags
C_CONTIGUOUS : True
F_CONTIGUOUS : True
OWNDATA : True
WRITEABLE : True
ALIGNED : True
WRITEBACKIFCOPY : False
>>> w.raw_data.astype(np.float64, copy=False).flags
C_CONTIGUOUS : False
F_CONTIGUOUS : False
OWNDATA : False
WRITEABLE : True
ALIGNED : True
WRITEBACKIFCOPY : False
Expected Behavior
When raw_data.dtype == np.float64 and scale_mode == NO_SCALING, scaled_data returns raw_data without making a copy.
Current Behavior
scaled_data always makes a copy.
Possible Solution
Add copy=False to the astype call in _convert_data.
Context
Reviewing nidaqmx changes.
Your Environment
N/A
AB#3262958
Bug Report
Testing with nidaqmx in ni/nidaqmx-python#828 revealed that AnalogWaveform.scaled_data always copies the data array.
Repro or Code Sample
Expected Behavior
When
raw_data.dtype==np.float64andscale_mode==NO_SCALING,scaled_datareturnsraw_datawithout making a copy.Current Behavior
scaled_dataalways makes a copy.Possible Solution
Add
copy=Falseto theastypecall in_convert_data.Context
Reviewing nidaqmx changes.
Your Environment
N/A
AB#3262958