Skip to content

Commit 99183ae

Browse files
authored
final remove dparray from RNG (#839)
1 parent 1f0c880 commit 99183ae

File tree

3 files changed

+37
-41
lines changed

3 files changed

+37
-41
lines changed

dpnp/random/dpnp_algo_random.pyx

Lines changed: 35 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,12 @@ and the rest of the library
3333
"""
3434

3535

36-
import numpy
3736
import dpnp.config as config
38-
3937
from dpnp.dpnp_algo cimport *
40-
from dpnp.dparray cimport dparray
4138

4239
cimport dpnp.dpnp_utils as utils
4340

41+
import numpy
4442
cimport numpy
4543

4644

@@ -147,7 +145,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_beta(double a, double b, size):
147145
148146
"""
149147

150-
# convert string type names (dparray.dtype) to C enum DPNPFuncType
148+
# convert string type names (array.dtype) to C enum DPNPFuncType
151149
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(numpy.float64)
152150

153151
# get the FPTR data structure
@@ -178,7 +176,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_binomial(int ntrial, double p, size):
178176
cdef DPNPFuncData kernel_data
179177
cdef fptr_dpnp_rng_binomial_c_1out_t func
180178

181-
# convert string type names (dparray.dtype) to C enum DPNPFuncType
179+
# convert string type names (array.dtype) to C enum DPNPFuncType
182180
param1_type = dpnp_dtype_to_DPNPFuncType(dtype)
183181

184182
# get the FPTR data structure
@@ -203,7 +201,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_chisquare(int df, size):
203201
204202
"""
205203

206-
# convert string type names (dparray.dtype) to C enum DPNPFuncType
204+
# convert string type names (array.dtype) to C enum DPNPFuncType
207205
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(numpy.float64)
208206

209207
# get the FPTR data structure
@@ -229,7 +227,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_exponential(double beta, size):
229227
"""
230228

231229
dtype = numpy.float64
232-
# convert string type names (dparray.dtype) to C enum DPNPFuncType
230+
# convert string type names (array.dtype) to C enum DPNPFuncType
233231
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(dtype)
234232

235233
# get the FPTR data structure
@@ -254,7 +252,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_f(double df_num, double df_den, size):
254252
"""
255253

256254
dtype = numpy.float64
257-
# convert string type names (dparray.dtype) to C enum DPNPFuncType
255+
# convert string type names (array.dtype) to C enum DPNPFuncType
258256
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(dtype)
259257

260258
# get the FPTR data structure
@@ -313,7 +311,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_geometric(float p, size):
313311
cdef DPNPFuncData kernel_data
314312
cdef fptr_dpnp_rng_geometric_c_1out_t func
315313

316-
# convert string type names (dparray.dtype) to C enum DPNPFuncType
314+
# convert string type names (array.dtype) to C enum DPNPFuncType
317315
param1_type = dpnp_dtype_to_DPNPFuncType(dtype)
318316

319317
# get the FPTR data structure
@@ -370,7 +368,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_hypergeometric(int l, int s, int m, size):
370368
cdef DPNPFuncData kernel_data
371369
cdef fptr_dpnp_rng_hypergeometric_c_1out_t func
372370

373-
# convert string type names (dparray.dtype) to C enum DPNPFuncType
371+
# convert string type names (array.dtype) to C enum DPNPFuncType
374372
param1_type = dpnp_dtype_to_DPNPFuncType(dtype)
375373

376374
# get the FPTR data structure
@@ -400,7 +398,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_laplace(double loc, double scale, size):
400398
cdef DPNPFuncData kernel_data
401399
cdef fptr_dpnp_rng_laplace_c_1out_t func
402400

403-
# convert string type names (dparray.dtype) to C enum DPNPFuncType
401+
# convert string type names (array.dtype) to C enum DPNPFuncType
404402
param1_type = dpnp_dtype_to_DPNPFuncType(dtype)
405403

406404
# get the FPTR data structure
@@ -425,7 +423,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_logistic(double loc, double scale, size):
425423
426424
"""
427425

428-
# convert string type names (dparray.dtype) to C enum DPNPFuncType
426+
# convert string type names (array.dtype) to C enum DPNPFuncType
429427
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(numpy.float64)
430428

431429
# get the FPTR data structure
@@ -455,7 +453,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_lognormal(double mean, double stddev, size)
455453
cdef DPNPFuncData kernel_data
456454
cdef fptr_dpnp_rng_lognormal_c_1out_t func
457455

458-
# convert string type names (dparray.dtype) to C enum DPNPFuncType
456+
# convert string type names (array.dtype) to C enum DPNPFuncType
459457
param1_type = dpnp_dtype_to_DPNPFuncType(dtype)
460458

461459
# get the FPTR data structure
@@ -491,7 +489,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_multinomial(int ntrial, p, size):
491489
cdef double * p_vector = <double * > numpy.PyArray_DATA(p)
492490
cdef size_t p_vector_size = len(p)
493491

494-
# convert string type names (dparray.dtype) to C enum DPNPFuncType
492+
# convert string type names (array.dtype) to C enum DPNPFuncType
495493
param1_type = dpnp_dtype_to_DPNPFuncType(dtype)
496494

497495
# get the FPTR data structure
@@ -534,7 +532,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_multivariate_normal(numpy.ndarray mean, num
534532
mean_vector_size = mean.size
535533
cov_vector_size = cov.size
536534

537-
# convert string type names (dparray.dtype) to C enum DPNPFuncType
535+
# convert string type names (array.dtype) to C enum DPNPFuncType
538536
param1_type = dpnp_dtype_to_DPNPFuncType(dtype)
539537

540538
# get the FPTR data structure
@@ -576,7 +574,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_negative_binomial(double a, double p, size)
576574
elif p == 1.0:
577575
return dpnp_full(size, 0, dtype)
578576
else:
579-
# convert string type names (dparray.dtype) to C enum DPNPFuncType
577+
# convert string type names (array.dtype) to C enum DPNPFuncType
580578
param1_type = dpnp_dtype_to_DPNPFuncType(dtype)
581579

582580
# get the FPTR data structure
@@ -601,7 +599,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_noncentral_chisquare(double df, double nonc
601599
602600
"""
603601

604-
# convert string type names (dparray.dtype) to C enum DPNPFuncType
602+
# convert string type names (array.dtype) to C enum DPNPFuncType
605603
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(numpy.float64)
606604

607605
# get the FPTR data structure
@@ -636,7 +634,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_normal(double loc, double scale, size):
636634
if scale == 0.0:
637635
return dpnp_full(size, loc, dtype)
638636
else:
639-
# convert string type names (dparray.dtype) to C enum DPNPFuncType
637+
# convert string type names (array.dtype) to C enum DPNPFuncType
640638
param1_type = dpnp_dtype_to_DPNPFuncType(dtype)
641639

642640
# get the FPTR data structure
@@ -662,7 +660,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_pareto(double alpha, size):
662660
"""
663661

664662
dtype = numpy.float64
665-
# convert string type names (dparray.dtype) to C enum DPNPFuncType
663+
# convert string type names (array.dtype) to C enum DPNPFuncType
666664
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(dtype)
667665

668666
# get the FPTR data structure
@@ -698,7 +696,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_poisson(double lam, size):
698696
if lam == 0:
699697
return dpnp_full(size, 0, dtype)
700698
else:
701-
# convert string type names (dparray.dtype) to C enum DPNPFuncType
699+
# convert string type names (array.dtype) to C enum DPNPFuncType
702700
param1_type = dpnp_dtype_to_DPNPFuncType(dtype)
703701

704702
# get the FPTR data structure
@@ -723,7 +721,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_power(double alpha, size):
723721
"""
724722

725723
dtype = numpy.float64
726-
# convert string type names (dparray.dtype) to C enum DPNPFuncType
724+
# convert string type names (array.dtype) to C enum DPNPFuncType
727725
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(dtype)
728726

729727
# get the FPTR data structure
@@ -750,7 +748,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_randn(dims):
750748
cdef double mean = 0.0
751749
cdef double stddev = 1.0
752750

753-
# convert string type names (dparray.dtype) to C enum DPNPFuncType
751+
# convert string type names (array.dtype) to C enum DPNPFuncType
754752
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(numpy.float64)
755753

756754
# get the FPTR data structure
@@ -776,7 +774,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_random(dims):
776774
cdef long low = 0
777775
cdef long high = 1
778776

779-
# convert string type names (dparray.dtype) to C enum DPNPFuncType
777+
# convert string type names (array.dtype) to C enum DPNPFuncType
780778
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(numpy.float64)
781779

782780
# get the FPTR data structure
@@ -811,7 +809,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_rayleigh(double scale, size):
811809
if scale == 0.0:
812810
return dpnp_full(size, 0.0, dtype)
813811
else:
814-
# convert string type names (dparray.dtype) to C enum DPNPFuncType
812+
# convert string type names (array.dtype) to C enum DPNPFuncType
815813
param1_type = dpnp_dtype_to_DPNPFuncType(dtype)
816814

817815
# get the FPTR data structure
@@ -834,7 +832,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_shuffle(utils.dpnp_descriptor x1):
834832
835833
"""
836834

837-
# convert string type names (dparray.dtype) to C enum DPNPFuncType
835+
# convert string type names (array.dtype) to C enum DPNPFuncType
838836
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(x1.dtype.type)
839837
cdef size_t itemsize = x1.dtype.itemsize
840838
cdef size_t ndim = x1.ndim
@@ -856,7 +854,7 @@ cpdef dpnp_rng_srand(seed):
856854
857855
"""
858856

859-
# convert string type names (dparray.dtype) to C enum DPNPFuncType
857+
# convert string type names (array.dtype) to C enum DPNPFuncType
860858
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(numpy.float64)
861859

862860
# get the FPTR data structure
@@ -875,7 +873,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_standard_cauchy(size):
875873
876874
"""
877875

878-
# convert string type names (dparray.dtype) to C enum DPNPFuncType
876+
# convert string type names (array.dtype) to C enum DPNPFuncType
879877
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(numpy.float64)
880878

881879
# get the FPTR data structure
@@ -902,7 +900,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_standard_exponential(size):
902900

903901
cdef fptr_dpnp_rng_standard_exponential_c_1out_t func
904902

905-
# convert string type names (dparray.dtype) to C enum DPNPFuncType
903+
# convert string type names (array.dtype) to C enum DPNPFuncType
906904
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(numpy.float64)
907905

908906
# get the FPTR data structure
@@ -937,7 +935,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_standard_gamma(double shape, size):
937935
if shape == 0.0:
938936
return dpnp_full(size, 0.0, dtype)
939937
else:
940-
# convert string type names (dparray.dtype) to C enum DPNPFuncType
938+
# convert string type names (array.dtype) to C enum DPNPFuncType
941939
param1_type = dpnp_dtype_to_DPNPFuncType(dtype)
942940

943941
# get the FPTR data structure
@@ -962,7 +960,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_standard_normal(size):
962960
963961
"""
964962

965-
# convert string type names (dparray.dtype) to C enum DPNPFuncType
963+
# convert string type names (array.dtype) to C enum DPNPFuncType
966964
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(numpy.float64)
967965

968966
# get the FPTR data structure
@@ -986,7 +984,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_standard_t(double df, size):
986984
987985
"""
988986

989-
# convert string type names (dparray.dtype) to C enum DPNPFuncType
987+
# convert string type names (array.dtype) to C enum DPNPFuncType
990988
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(numpy.float64)
991989

992990
# get the FPTR data structure
@@ -1012,7 +1010,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_triangular(double left, double mode, double
10121010
"""
10131011

10141012
dtype = numpy.float64
1015-
# convert string type names (dparray.dtype) to C enum DPNPFuncType
1013+
# convert string type names (array.dtype) to C enum DPNPFuncType
10161014
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(dtype)
10171015

10181016
# get the FPTR data structure
@@ -1047,7 +1045,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_uniform(long low, long high, size, dtype):
10471045
if low == high:
10481046
return dpnp_full(size, low, dtype)
10491047
else:
1050-
# convert string type names (dparray.dtype) to C enum DPNPFuncType
1048+
# convert string type names (array.dtype) to C enum DPNPFuncType
10511049
param1_type = dpnp_dtype_to_DPNPFuncType(dtype)
10521050

10531051
# get the FPTR data structure
@@ -1072,7 +1070,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_vonmises(double mu, double kappa, size):
10721070
10731071
"""
10741072

1075-
# convert string type names (dparray.dtype) to C enum DPNPFuncType
1073+
# convert string type names (array.dtype) to C enum DPNPFuncType
10761074
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(numpy.float64)
10771075

10781076
# get the FPTR data structure
@@ -1098,7 +1096,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_wald(double mean, double scale, size):
10981096
"""
10991097

11001098
dtype = numpy.float64
1101-
# convert string type names (dparray.dtype) to C enum DPNPFuncType
1099+
# convert string type names (array.dtype) to C enum DPNPFuncType
11021100
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(dtype)
11031101

11041102
# get the FPTR data structure
@@ -1128,7 +1126,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_weibull(double a, size):
11281126
cdef DPNPFuncData kernel_data
11291127
cdef fptr_dpnp_rng_weibull_c_1out_t func
11301128

1131-
# convert string type names (dparray.dtype) to C enum DPNPFuncType
1129+
# convert string type names (array.dtype) to C enum DPNPFuncType
11321130
param1_type = dpnp_dtype_to_DPNPFuncType(numpy.float64)
11331131

11341132
# get the FPTR data structure
@@ -1153,7 +1151,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_zipf(double a, size):
11531151
11541152
"""
11551153

1156-
# convert string type names (dparray.dtype) to C enum DPNPFuncType
1154+
# convert string type names (array.dtype) to C enum DPNPFuncType
11571155
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(numpy.float64)
11581156

11591157
# get the FPTR data structure

dpnp/random/dpnp_iface_random.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import numpy
4040

4141
from dpnp.dpnp_algo import *
42-
from dpnp.dparray import dparray
4342
from dpnp.dpnp_utils import *
4443
from dpnp.random.dpnp_algo_random import *
4544

@@ -1298,7 +1297,6 @@ def shuffle(x1):
12981297
12991298
Limitations
13001299
-----------
1301-
Parameter ``x`` is supported as a ``dpnp.dparray``.
13021300
Otherwise, the function will use :obj:`numpy.random.shuffle` on the backend
13031301
and will be executed on fallback backend.
13041302

tests/test_random.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,7 @@ def test_no_miss_numbers(self, dtype):
964964
@pytest.mark.parametrize("conv", [lambda x: dpnp.array([]),
965965
lambda x: dpnp.asarray(x).astype(dpnp.int8),
966966
lambda x: dpnp.asarray(x).astype(dpnp.float32),
967-
lambda x: dpnp.asarray(x).astype(dpnp.complex64),
967+
# lambda x: dpnp.asarray(x).astype(dpnp.complex64),
968968
lambda x: dpnp.asarray(x).astype(object),
969969
lambda x: dpnp.asarray([[i, i] for i in x]),
970970
lambda x: dpnp.vstack([x, x]).T,
@@ -975,7 +975,7 @@ def test_no_miss_numbers(self, dtype):
975975
ids=['lambda x: dpnp.array([])',
976976
'lambda x: dpnp.asarray(x).astype(dpnp.int8)',
977977
'lambda x: dpnp.asarray(x).astype(dpnp.float32)',
978-
'lambda x: dpnp.asarray(x).astype(dpnp.complex64)',
978+
# 'lambda x: dpnp.asarray(x).astype(dpnp.complex64)',
979979
'lambda x: dpnp.asarray(x).astype(object)',
980980
'lambda x: dpnp.asarray([[i, i] for i in x])',
981981
'lambda x: dpnp.vstack([x, x]).T',

0 commit comments

Comments
 (0)