@@ -57,15 +57,15 @@ def test_distr(self, dtype, usm_type):
57
57
58
58
# default dtype depends on fp64 support by the device
59
59
dtype = get_default_floating () if dtype is None else dtype
60
- desired = numpy .array ([[0.428205496031286 , - 0.55383273779227 ],
61
- [2.027017795643378 , 4.318888073163015 ],
62
- [2.69080893259102 , - 1.047967253719708 ]], dtype = dtype )
60
+ expected = numpy .array ([[0.428205496031286 , - 0.55383273779227 ],
61
+ [2.027017795643378 , 4.318888073163015 ],
62
+ [2.69080893259102 , - 1.047967253719708 ]], dtype = dtype )
63
63
64
64
# TODO: discuss with opneMKL: there is a difference between CPU and GPU
65
65
# generated samples since 9 digit while precision=15 for float64
66
66
# precision = numpy.finfo(dtype=dtype).precision
67
67
precision = 8 if dtype == dpnp .float64 else numpy .finfo (dtype = dtype ).precision
68
- assert_array_almost_equal (dpnp_data .asnumpy (), desired , decimal = precision )
68
+ assert_array_almost_equal (dpnp_data .asnumpy (), expected , decimal = precision )
69
69
70
70
# check if compute follows data isn't broken
71
71
assert_cfd (dpnp_data , sycl_queue , usm_type )
@@ -162,11 +162,11 @@ def test_fallback(self, loc, scale):
162
162
163
163
# dpnp accepts only scalar as low and/or high, in other cases it will be a fallback to numpy
164
164
actual = data .asnumpy ()
165
- desired = numpy .random .RandomState (seed ).normal (loc = loc , scale = scale , size = size )
165
+ expected = numpy .random .RandomState (seed ).normal (loc = loc , scale = scale , size = size )
166
166
167
167
dtype = get_default_floating ()
168
168
precision = numpy .finfo (dtype = dtype ).precision
169
- assert_array_almost_equal (actual , desired , decimal = precision )
169
+ assert_array_almost_equal (actual , expected , decimal = precision )
170
170
171
171
# check if compute follows data isn't broken
172
172
assert_cfd (data , sycl_queue )
@@ -200,22 +200,22 @@ def test_distr(self, usm_type):
200
200
dtype = get_default_floating ()
201
201
202
202
data = RandomState (seed , sycl_queue = sycl_queue ).rand (3 , 2 , usm_type = usm_type )
203
- desired = numpy .array ([[0.7592552667483687 , 0.5937560645397753 ],
204
- [0.257010098779574 , 0.749422621447593 ],
205
- [0.6316644293256104 , 0.7411410815548152 ]], dtype = dtype )
203
+ expected = numpy .array ([[0.7592552667483687 , 0.5937560645397753 ],
204
+ [0.257010098779574 , 0.749422621447593 ],
205
+ [0.6316644293256104 , 0.7411410815548152 ]], dtype = dtype )
206
206
207
207
precision = numpy .finfo (dtype = numpy .float64 ).precision
208
- assert_array_almost_equal (data .asnumpy (), desired , decimal = precision )
208
+ assert_array_almost_equal (data .asnumpy (), expected , decimal = precision )
209
209
assert_cfd (data , sycl_queue , usm_type )
210
210
211
211
# call with the same seed has to draw the same values
212
212
data = RandomState (seed , sycl_queue = sycl_queue ).rand (3 , 2 , usm_type = usm_type )
213
- assert_array_almost_equal (data .asnumpy (), desired , decimal = precision )
213
+ assert_array_almost_equal (data .asnumpy (), expected , decimal = precision )
214
214
assert_cfd (data , sycl_queue , usm_type )
215
215
216
- # call with omitted dimensions has to draw the first element from desired
216
+ # call with omitted dimensions has to draw the first element from expected
217
217
data = RandomState (seed , sycl_queue = sycl_queue ).rand (usm_type = usm_type )
218
- assert_array_almost_equal (data .asnumpy (), desired [0 , 0 ], decimal = precision )
218
+ assert_array_almost_equal (data .asnumpy (), expected [0 , 0 ], decimal = precision )
219
219
assert_cfd (data , sycl_queue , usm_type )
220
220
221
221
# rand() is an alias on random_sample(), map arguments
@@ -276,10 +276,10 @@ def test_distr(self, dtype, usm_type):
276
276
size = (3 , 2 ),
277
277
dtype = dtype ,
278
278
usm_type = usm_type )
279
- desired = numpy .array ([[4 , 1 ],
280
- [5 , 3 ],
281
- [5 , 7 ]], dtype = numpy .int32 )
282
- assert_array_equal (data .asnumpy (), desired )
279
+ expected = numpy .array ([[4 , 1 ],
280
+ [5 , 3 ],
281
+ [5 , 7 ]], dtype = numpy .int32 )
282
+ assert_array_equal (data .asnumpy (), expected )
283
283
assert_cfd (data , sycl_queue , usm_type )
284
284
285
285
# call with the same seed has to draw the same values
@@ -288,15 +288,15 @@ def test_distr(self, dtype, usm_type):
288
288
size = (3 , 2 ),
289
289
dtype = dtype ,
290
290
usm_type = usm_type )
291
- assert_array_equal (data .asnumpy (), desired )
291
+ assert_array_equal (data .asnumpy (), expected )
292
292
assert_cfd (data , sycl_queue , usm_type )
293
293
294
- # call with omitted dimensions has to draw the first element from desired
294
+ # call with omitted dimensions has to draw the first element from expected
295
295
data = RandomState (seed , sycl_queue = sycl_queue ).randint (low = low ,
296
296
high = high ,
297
297
dtype = dtype ,
298
298
usm_type = usm_type )
299
- assert_array_equal (data .asnumpy (), desired [0 , 0 ])
299
+ assert_array_equal (data .asnumpy (), expected [0 , 0 ])
300
300
assert_cfd (data , sycl_queue , usm_type )
301
301
302
302
# rand() is an alias on random_sample(), map arguments
@@ -311,15 +311,15 @@ def test_distr(self, dtype, usm_type):
311
311
312
312
def test_float_bounds (self ):
313
313
actual = RandomState (365852 ).randint (low = 0.6 , high = 6.789102534 , size = (7 ,)).asnumpy ()
314
- desired = numpy .array ([4 , 4 , 3 , 3 , 1 , 0 , 3 ], dtype = numpy .int32 )
315
- assert_array_equal (actual , desired )
314
+ expected = numpy .array ([4 , 4 , 3 , 3 , 1 , 0 , 3 ], dtype = numpy .int32 )
315
+ assert_array_equal (actual , expected )
316
316
317
317
318
318
def test_negative_bounds (self ):
319
319
actual = RandomState (5143 ).randint (low = - 15.74 , high = - 3 , size = (2 , 7 )).asnumpy ()
320
- desired = numpy .array ([[- 9 , - 12 , - 4 , - 12 , - 5 , - 13 , - 9 ],
321
- [- 4 , - 6 , - 13 , - 9 , - 9 , - 6 , - 15 ]], dtype = numpy .int32 )
322
- assert_array_equal (actual , desired )
320
+ expected = numpy .array ([[- 9 , - 12 , - 4 , - 12 , - 5 , - 13 , - 9 ],
321
+ [- 4 , - 6 , - 13 , - 9 , - 9 , - 6 , - 15 ]], dtype = numpy .int32 )
322
+ assert_array_equal (actual , expected )
323
323
324
324
325
325
def test_negative_interval (self ):
@@ -417,8 +417,8 @@ def test_bounds_fallback(self, low, high):
417
417
418
418
# dpnp accepts only scalar as low and/or high, in other cases it will be a fallback to numpy
419
419
actual = RandomState (seed ).randint (low = low , high = high , size = size ).asnumpy ()
420
- desired = numpy .random .RandomState (seed ).randint (low = low , high = high , size = size )
421
- assert_equal (actual , desired )
420
+ expected = numpy .random .RandomState (seed ).randint (low = low , high = high , size = size )
421
+ assert_equal (actual , expected )
422
422
423
423
424
424
@pytest .mark .usefixtures ("allow_fall_back_on_numpy" )
@@ -436,8 +436,8 @@ def test_dtype_fallback(self, dtype):
436
436
437
437
# dtype must be int or dpnp.int32, in other cases it will be a fallback to numpy
438
438
actual = RandomState (seed ).randint (low = low , high = high , size = size , dtype = dtype ).asnumpy ()
439
- desired = numpy .random .RandomState (seed ).randint (low = low , high = high , size = size , dtype = dtype )
440
- assert_equal (actual , desired )
439
+ expected = numpy .random .RandomState (seed ).randint (low = low , high = high , size = size , dtype = dtype )
440
+ assert_equal (actual , expected )
441
441
assert_raises (TypeError , RandomState ().randint , dtype = dtype )
442
442
443
443
@@ -459,23 +459,23 @@ def test_distr(self, usm_type):
459
459
dtype = get_default_floating ()
460
460
461
461
data = RandomState (seed , sycl_queue = sycl_queue ).randn (3 , 2 , usm_type = usm_type )
462
- desired = numpy .array ([[- 0.862485623762009 , 1.169492612490272 ],
462
+ expected = numpy .array ([[- 0.862485623762009 , 1.169492612490272 ],
463
463
[- 0.405876118480338 , 0.939006537666719 ],
464
464
[- 0.615075625641019 , 0.555260469834381 ]], dtype = dtype )
465
465
466
466
# TODO: discuss with opneMKL: there is a difference between CPU and GPU
467
467
# generated samples since 9 digit while precision=15 for float64
468
468
# precision = numpy.finfo(dtype=numpy.float64).precision
469
469
precision = numpy .finfo (dtype = numpy .float32 ).precision
470
- assert_array_almost_equal (data .asnumpy (), desired , decimal = precision )
470
+ assert_array_almost_equal (data .asnumpy (), expected , decimal = precision )
471
471
472
472
# call with the same seed has to draw the same values
473
473
data = RandomState (seed , sycl_queue = sycl_queue ).randn (3 , 2 , usm_type = usm_type )
474
- assert_array_almost_equal (data .asnumpy (), desired , decimal = precision )
474
+ assert_array_almost_equal (data .asnumpy (), expected , decimal = precision )
475
475
476
- # call with omitted dimensions has to draw the first element from desired
476
+ # call with omitted dimensions has to draw the first element from expected
477
477
actual = dpnp .asnumpy (RandomState (seed ).randn (usm_type = usm_type ))
478
- assert_array_almost_equal (actual , desired [0 , 0 ], decimal = precision )
478
+ assert_array_almost_equal (actual , expected [0 , 0 ], decimal = precision )
479
479
480
480
# randn() is an alias on standard_normal(), map arguments
481
481
with mock .patch ('dpnp.random.RandomState.standard_normal' ) as m :
@@ -610,24 +610,24 @@ def test_distr(self, usm_type):
610
610
dtype = get_default_floating ()
611
611
612
612
data = RandomState (seed , sycl_queue = sycl_queue ).standard_normal (size = (4 , 2 ), usm_type = usm_type )
613
- desired = numpy .array ([[0.112455902594571 , - 0.249919829443642 ],
614
- [0.702423540827815 , 1.548132130318456 ],
615
- [0.947364919775284 , - 0.432257289195464 ],
616
- [0.736848611436872 , 1.557284323302839 ]], dtype = dtype )
613
+ expected = numpy .array ([[0.112455902594571 , - 0.249919829443642 ],
614
+ [0.702423540827815 , 1.548132130318456 ],
615
+ [0.947364919775284 , - 0.432257289195464 ],
616
+ [0.736848611436872 , 1.557284323302839 ]], dtype = dtype )
617
617
618
618
# TODO: discuss with opneMKL: there is a difference between CPU and GPU
619
619
# generated samples since 9 digit while precision=15 for float64
620
620
# precision = numpy.finfo(dtype=numpy.float64).precision
621
621
precision = numpy .finfo (dtype = numpy .float32 ).precision
622
- assert_array_almost_equal (data .asnumpy (), desired , decimal = precision )
622
+ assert_array_almost_equal (data .asnumpy (), expected , decimal = precision )
623
623
624
624
# call with the same seed has to draw the same values
625
625
data = RandomState (seed , sycl_queue = sycl_queue ).standard_normal (size = (4 , 2 ), usm_type = usm_type )
626
- assert_array_almost_equal (data .asnumpy (), desired , decimal = precision )
626
+ assert_array_almost_equal (data .asnumpy (), expected , decimal = precision )
627
627
628
- # call with omitted dimensions has to draw the first element from desired
628
+ # call with omitted dimensions has to draw the first element from expected
629
629
actual = dpnp .asnumpy (RandomState (seed ).standard_normal (usm_type = usm_type ))
630
- assert_array_almost_equal (actual , desired [0 , 0 ], decimal = precision )
630
+ assert_array_almost_equal (actual , expected [0 , 0 ], decimal = precision )
631
631
632
632
# random_sample() is an alias on uniform(), map arguments
633
633
with mock .patch ('dpnp.random.RandomState.normal' ) as m :
@@ -670,17 +670,17 @@ def test_distr(self, usm_type):
670
670
dtype = get_default_floating ()
671
671
672
672
data = RandomState (seed , sycl_queue = sycl_queue ).random_sample (size = (4 , 2 ), usm_type = usm_type )
673
- desired = numpy .array ([[0.1887628440745175 , 0.2763057765550911 ],
674
- [0.3973943444434553 , 0.2975987731479108 ],
675
- [0.4144027342554182 , 0.2636592474300414 ],
676
- [0.6129623607266694 , 0.2596735346596688 ]], dtype = dtype )
673
+ expected = numpy .array ([[0.1887628440745175 , 0.2763057765550911 ],
674
+ [0.3973943444434553 , 0.2975987731479108 ],
675
+ [0.4144027342554182 , 0.2636592474300414 ],
676
+ [0.6129623607266694 , 0.2596735346596688 ]], dtype = dtype )
677
677
678
678
precision = numpy .finfo (dtype = dtype ).precision
679
- assert_array_almost_equal (data .asnumpy (), desired , decimal = precision )
679
+ assert_array_almost_equal (data .asnumpy (), expected , decimal = precision )
680
680
681
- # call with omitted dimensions has to draw the first element from desired
681
+ # call with omitted dimensions has to draw the first element from expected
682
682
data = RandomState (seed , sycl_queue = sycl_queue ).random_sample (usm_type = usm_type )
683
- assert_array_almost_equal (data .asnumpy (), desired [0 , 0 ], decimal = precision )
683
+ assert_array_almost_equal (data .asnumpy (), expected [0 , 0 ], decimal = precision )
684
684
685
685
# random_sample() is an alias on uniform(), map arguments
686
686
with mock .patch ('dpnp.random.RandomState.uniform' ) as m :
@@ -747,15 +747,15 @@ def test_distr(self, bounds, dtype, usm_type):
747
747
# default dtype depends on fp64 support by the device
748
748
dtype = get_default_floating () if dtype is None else dtype
749
749
if dtype != dpnp .int32 :
750
- desired = numpy .array ([[4.023770128630567 , 8.87456423597643 ],
751
- [2.888630247435067 , 4.823004481580574 ],
752
- [2.030351535445079 , 4.533497077834326 ]])
753
- assert_array_almost_equal (actual , desired , decimal = numpy .finfo (dtype = dtype ).precision )
750
+ expected = numpy .array ([[4.023770128630567 , 8.87456423597643 ],
751
+ [2.888630247435067 , 4.823004481580574 ],
752
+ [2.030351535445079 , 4.533497077834326 ]])
753
+ assert_array_almost_equal (actual , expected , decimal = numpy .finfo (dtype = dtype ).precision )
754
754
else :
755
- desired = numpy .array ([[3 , 8 ],
755
+ expected = numpy .array ([[3 , 8 ],
756
756
[2 , 4 ],
757
757
[1 , 4 ]])
758
- assert_array_equal (actual , desired )
758
+ assert_array_equal (actual , expected )
759
759
760
760
# check if compute follows data isn't broken
761
761
assert_cfd (dpnp_data , sycl_queue , usm_type )
@@ -784,12 +784,12 @@ def test_low_high_equal(self, dtype, usm_type):
784
784
785
785
# default dtype depends on fp64 support by the device
786
786
dtype = get_default_floating () if dtype is None else dtype
787
- desired = numpy .full (shape = shape , fill_value = low , dtype = dtype )
787
+ expected = numpy .full (shape = shape , fill_value = low , dtype = dtype )
788
788
789
789
if dtype == dpnp .int32 :
790
- assert_array_equal (actual , desired )
790
+ assert_array_equal (actual , expected )
791
791
else :
792
- assert_array_almost_equal (actual , desired , decimal = numpy .finfo (dtype = dtype ).precision )
792
+ assert_array_almost_equal (actual , expected , decimal = numpy .finfo (dtype = dtype ).precision )
793
793
794
794
795
795
@pytest .mark .usefixtures ("allow_fall_back_on_numpy" )
@@ -824,11 +824,11 @@ def test_fallback(self, low, high):
824
824
825
825
# dpnp accepts only scalar as low and/or high, in other cases it will be a fallback to numpy
826
826
actual = data .asnumpy ()
827
- desired = numpy .random .RandomState (seed ).uniform (low = low , high = high , size = size )
827
+ expected = numpy .random .RandomState (seed ).uniform (low = low , high = high , size = size )
828
828
829
829
dtype = get_default_floating ()
830
830
precision = numpy .finfo (dtype = dtype ).precision
831
- assert_array_almost_equal (actual , desired , decimal = precision )
831
+ assert_array_almost_equal (actual , expected , decimal = precision )
832
832
833
833
# check if compute follows data isn't broken
834
834
assert_cfd (data , sycl_queue )
0 commit comments