@@ -64,7 +64,8 @@ def test___ai_finite_task___readall___returns_valid_samples_shape_and_dtype(
64
64
rate = 1000.0 , sample_mode = AcquisitionType .FINITE , samps_per_chan = 100
65
65
)
66
66
67
- data = ai_sine_task .in_stream .readall ()
67
+ with pytest .deprecated_call ():
68
+ data = ai_sine_task .in_stream .readall ()
68
69
69
70
assert data .shape == (ai_sine_task .number_of_channels * 100 ,)
70
71
assert data .dtype == numpy .int16
@@ -83,7 +84,8 @@ def test___ai_continuous_task___readall___returns_valid_samples_shape_and_dtype(
83
84
while ai_sine_task .in_stream .avail_samp_per_chan < min_samples_per_channel :
84
85
time .sleep (10e-3 )
85
86
86
- data = ai_sine_task .in_stream .readall ()
87
+ with pytest .deprecated_call ():
88
+ data = ai_sine_task .in_stream .readall ()
87
89
88
90
assert data .shape [0 ] >= ai_sine_task .number_of_channels * min_samples_per_channel
89
91
assert data .shape [0 ] % ai_sine_task .number_of_channels == 0
@@ -100,7 +102,8 @@ def test___valid_array___readinto___returns_valid_samples(
100
102
ai_sine_task .number_of_channels * samples_to_read , FULLSCALE_RAW_MAX , dtype = numpy .int16
101
103
)
102
104
103
- samples_read = ai_sine_task .in_stream .readinto (data )
105
+ with pytest .deprecated_call ():
106
+ samples_read = ai_sine_task .in_stream .readinto (data )
104
107
105
108
assert samples_read == samples_to_read
106
109
assert (SINE_RAW_MIN <= data ).all () and (data <= SINE_RAW_MAX ).all ()
@@ -113,7 +116,71 @@ def test___odd_sized_array___readinto___returns_whole_samples_and_clears_padding
113
116
# Initialize the array to full-scale readings to ensure it is overwritten.
114
117
data = numpy .full (19 , FULLSCALE_RAW_MIN , dtype = numpy .int16 )
115
118
116
- samples_read = task .in_stream .readinto (data )
119
+ with pytest .deprecated_call ():
120
+ samples_read = task .in_stream .readinto (data )
121
+
122
+ assert samples_read == 9
123
+ assert (SINE_RAW_MIN <= data [:- 1 ]).all () and (data [:- 1 ] <= SINE_RAW_MAX ).all ()
124
+ assert data [- 1 ] == 0 # not FULLSCALE_RAW_MIN
125
+
126
+
127
+ def test___ai_finite_task___read_all___returns_valid_samples_shape_and_dtype (
128
+ ai_sine_task : nidaqmx .Task ,
129
+ ) -> None :
130
+ ai_sine_task .timing .cfg_samp_clk_timing (
131
+ rate = 1000.0 , sample_mode = AcquisitionType .FINITE , samps_per_chan = 100
132
+ )
133
+
134
+ data = ai_sine_task .in_stream .read_all ()
135
+
136
+ assert data .shape == (ai_sine_task .number_of_channels * 100 ,)
137
+ assert data .dtype == numpy .int16
138
+ assert (SINE_RAW_MIN <= data ).all () and (data <= SINE_RAW_MAX ).all ()
139
+
140
+
141
+ def test___ai_continuous_task___read_all___returns_valid_samples_shape_and_dtype (
142
+ ai_sine_task : nidaqmx .Task ,
143
+ ) -> None :
144
+ ai_sine_task .timing .cfg_samp_clk_timing (
145
+ rate = 1000.0 , sample_mode = AcquisitionType .CONTINUOUS , samps_per_chan = 1000
146
+ )
147
+ ai_sine_task .start ()
148
+ # Wait until there are some samples to read.
149
+ min_samples_per_channel = 100
150
+ while ai_sine_task .in_stream .avail_samp_per_chan < min_samples_per_channel :
151
+ time .sleep (10e-3 )
152
+
153
+ data = ai_sine_task .in_stream .read_all ()
154
+
155
+ assert data .shape [0 ] >= ai_sine_task .number_of_channels * min_samples_per_channel
156
+ assert data .shape [0 ] % ai_sine_task .number_of_channels == 0
157
+ assert data .dtype == numpy .int16
158
+ assert (SINE_RAW_MIN <= data ).all () and (data <= SINE_RAW_MAX ).all ()
159
+
160
+
161
+ @pytest .mark .parametrize ("samples_to_read" , [1 , 10 ])
162
+ def test___valid_array___read_into___returns_valid_samples (
163
+ ai_sine_task : nidaqmx .Task , samples_to_read : int
164
+ ) -> None :
165
+ # Initialize the array to full-scale readings to ensure it is overwritten.
166
+ data = numpy .full (
167
+ ai_sine_task .number_of_channels * samples_to_read , FULLSCALE_RAW_MAX , dtype = numpy .int16
168
+ )
169
+
170
+ samples_read = ai_sine_task .in_stream .read_into (data )
171
+
172
+ assert samples_read == samples_to_read
173
+ assert (SINE_RAW_MIN <= data ).all () and (data <= SINE_RAW_MAX ).all ()
174
+
175
+
176
+ def test___odd_sized_array___read_into___returns_whole_samples_and_clears_padding (
177
+ task : nidaqmx .Task , sim_x_series_device : nidaqmx .system .Device
178
+ ) -> None :
179
+ _create_ai_sine_channels (task , sim_x_series_device , number_of_channels = 2 )
180
+ # Initialize the array to full-scale readings to ensure it is overwritten.
181
+ data = numpy .full (19 , FULLSCALE_RAW_MIN , dtype = numpy .int16 )
182
+
183
+ samples_read = task .in_stream .read_into (data )
117
184
118
185
assert samples_read == 9
119
186
assert (SINE_RAW_MIN <= data [:- 1 ]).all () and (data [:- 1 ] <= SINE_RAW_MAX ).all ()
0 commit comments