Skip to content

Commit b324990

Browse files
DEP: removed size check. random (#357)
* DEP: removed size check. random
1 parent cdc9bcd commit b324990

File tree

1 file changed

+0
-165
lines changed

1 file changed

+0
-165
lines changed

dpnp/random/dpnp_iface_random.py

Lines changed: 0 additions & 165 deletions
Original file line numberDiff line numberDiff line change
@@ -327,15 +327,6 @@ def exponential(scale=1.0, size=None):
327327
"""
328328

329329
if not use_origin_backend(scale):
330-
if size is None:
331-
size = 1
332-
elif isinstance(size, tuple):
333-
for dim in size:
334-
if not isinstance(dim, int):
335-
checker_throw_value_error("exponential", "type(dim)", type(dim), int)
336-
elif not isinstance(size, int):
337-
checker_throw_value_error("exponential", "type(size)", type(size), int)
338-
339330
if scale < 0:
340331
checker_throw_value_error("exponential", "scale", scale, "non-negative")
341332

@@ -413,15 +404,6 @@ def gamma(shape, scale=1.0, size=None):
413404
# TODO:
414405
# array_like of floats for `scale` and `shape`
415406
if not use_origin_backend(scale) and dpnp_queue_is_cpu():
416-
if size is None:
417-
size = 1
418-
elif isinstance(size, tuple):
419-
for dim in size:
420-
if not isinstance(dim, int):
421-
checker_throw_value_error("gamma", "type(dim)", type(dim), int)
422-
elif not isinstance(size, int):
423-
checker_throw_value_error("gamma", "type(size)", type(size), int)
424-
425407
if scale < 0:
426408
checker_throw_value_error("gamma", "scale", scale, "non-negative")
427409
if shape < 0:
@@ -472,15 +454,6 @@ def geometric(p, size=None):
472454
"""
473455

474456
if not use_origin_backend(p):
475-
if size is None:
476-
size = 1
477-
elif isinstance(size, tuple):
478-
for dim in size:
479-
if not isinstance(dim, int):
480-
checker_throw_value_error("geometric", "type(dim)", type(dim), int)
481-
elif not isinstance(size, int):
482-
checker_throw_value_error("geometric", "type(size)", type(size), int)
483-
484457
# TODO:
485458
# array_like of floats for `p` param
486459
if p > 1 or p <= 0:
@@ -525,15 +498,6 @@ def gumbel(loc=0.0, scale=1.0, size=None):
525498
"""
526499

527500
if not use_origin_backend(loc):
528-
if size is None:
529-
size = 1
530-
elif isinstance(size, tuple):
531-
for dim in size:
532-
if not isinstance(dim, int):
533-
checker_throw_value_error("gumbel", "type(dim)", type(dim), int)
534-
elif not isinstance(size, int):
535-
checker_throw_value_error("gumbel", "type(size)", type(size), int)
536-
537501
# TODO:
538502
# array_like of floats for `loc` and `scale` params
539503
if scale < 0:
@@ -618,15 +582,6 @@ def hypergeometric(ngood, nbad, nsample, size=None):
618582
"""
619583

620584
if not use_origin_backend(ngood) and dpnp_queue_is_cpu():
621-
if size is None:
622-
size = 1
623-
elif isinstance(size, tuple):
624-
for dim in size:
625-
if not isinstance(dim, int):
626-
checker_throw_value_error("hypergeometric", "type(dim)", type(dim), int)
627-
elif not isinstance(size, int):
628-
checker_throw_value_error("hypergeometric", "type(size)", type(size), int)
629-
630585
# TODO:
631586
# array_like of ints for `ngood`, `nbad`, `nsample` param
632587
if ngood < 0:
@@ -685,15 +640,6 @@ def laplace(loc=0.0, scale=1.0, size=None):
685640
"""
686641

687642
if not use_origin_backend(loc):
688-
if size is None:
689-
size = 1
690-
elif isinstance(size, tuple):
691-
for dim in size:
692-
if not isinstance(dim, int):
693-
checker_throw_value_error("laplace", "type(dim)", type(dim), int)
694-
elif not isinstance(size, int):
695-
checker_throw_value_error("laplace", "type(size)", type(size), int)
696-
697643
# TODO:
698644
# array_like of floats for `loc` and `scale` params
699645
if scale < 0:
@@ -783,15 +729,6 @@ def lognormal(mean=0.0, sigma=1.0, size=None):
783729
"""
784730

785731
if not use_origin_backend(mean):
786-
if size is None:
787-
size = 1
788-
elif isinstance(size, tuple):
789-
for dim in size:
790-
if not isinstance(dim, int):
791-
checker_throw_value_error("lognormal", "type(dim)", type(dim), int)
792-
elif not isinstance(size, int):
793-
checker_throw_value_error("lognormal", "type(size)", type(size), int)
794-
795732
# TODO:
796733
# array_like of floats for `mean` and `sigma` params
797734
if sigma < 0:
@@ -1077,15 +1014,6 @@ def negative_binomial(n, p, size=None):
10771014
"""
10781015

10791016
if not use_origin_backend(n) and dpnp_queue_is_cpu():
1080-
if size is None:
1081-
size = 1
1082-
elif isinstance(size, tuple):
1083-
for dim in size:
1084-
if not isinstance(dim, int):
1085-
checker_throw_value_error("negative_binomial", "type(dim)", type(dim), int)
1086-
elif not isinstance(size, int):
1087-
checker_throw_value_error("negative_binomial", "type(size)", type(size), int)
1088-
10891017
# TODO:
10901018
# array_like of floats for `p` and `n` params
10911019
if p > 1 or p < 0:
@@ -1164,15 +1092,6 @@ def normal(loc=0.0, scale=1.0, size=None):
11641092
"""
11651093

11661094
if not use_origin_backend(loc):
1167-
if size is None:
1168-
size = 1
1169-
elif isinstance(size, tuple):
1170-
for dim in size:
1171-
if not isinstance(dim, int):
1172-
checker_throw_value_error("normal", "type(dim)", type(dim), int)
1173-
elif not isinstance(size, int):
1174-
checker_throw_value_error("normal", "type(size)", type(size), int)
1175-
11761095
# TODO:
11771096
# array_like of floats for `loc` and `scale` params
11781097
if scale < 0:
@@ -1301,15 +1220,6 @@ def poisson(lam=1.0, size=None):
13011220
"""
13021221

13031222
if not use_origin_backend(lam):
1304-
if size is None:
1305-
size = 1
1306-
elif isinstance(size, tuple):
1307-
for dim in size:
1308-
if not isinstance(dim, int):
1309-
checker_throw_value_error("poisson", "type(dim)", type(dim), int)
1310-
elif not isinstance(size, int):
1311-
checker_throw_value_error("poisson", "type(size)", type(size), int)
1312-
13131223
# TODO:
13141224
# array_like of floats for `lam` param
13151225
if lam < 0:
@@ -1409,15 +1319,6 @@ def randint(low, high=None, size=None, dtype=int):
14091319
"""
14101320

14111321
if not use_origin_backend(low):
1412-
if size is None:
1413-
size = 1
1414-
elif isinstance(size, tuple):
1415-
for dim in size:
1416-
if not isinstance(dim, int):
1417-
checker_throw_value_error("randint", "type(dim)", type(dim), int)
1418-
elif not isinstance(size, int):
1419-
checker_throw_value_error("randint", "type(size)", type(size), int)
1420-
14211322
if high is None:
14221323
high = low
14231324
low = 0
@@ -1564,9 +1465,6 @@ def random_sample(size):
15641465
"""
15651466

15661467
if not use_origin_backend(size):
1567-
for dim in size:
1568-
if not isinstance(dim, int):
1569-
checker_throw_value_error("random_sample", "type(dim)", type(dim), int)
15701468
return dpnp_random(size)
15711469

15721470
return call_origin(numpy.random.random_sample, size)
@@ -1592,9 +1490,6 @@ def ranf(size):
15921490
"""
15931491

15941492
if not use_origin_backend(size):
1595-
for dim in size:
1596-
if not isinstance(dim, int):
1597-
checker_throw_value_error("ranf", "type(dim)", type(dim), int)
15981493
return dpnp_random(size)
15991494

16001495
return call_origin(numpy.random.ranf, size)
@@ -1625,15 +1520,6 @@ def rayleigh(scale=1.0, size=None):
16251520
"""
16261521

16271522
if not use_origin_backend(scale):
1628-
if size is None:
1629-
size = 1
1630-
elif isinstance(size, tuple):
1631-
for dim in size:
1632-
if not isinstance(dim, int):
1633-
checker_throw_value_error("rayleigh", "type(dim)", type(dim), int)
1634-
elif not isinstance(size, int):
1635-
checker_throw_value_error("rayleigh", "type(size)", type(size), int)
1636-
16371523
# TODO:
16381524
# array_like of floats for `scale` params
16391525
if scale < 0:
@@ -1664,9 +1550,6 @@ def sample(size):
16641550
"""
16651551

16661552
if not use_origin_backend(size):
1667-
for dim in size:
1668-
if not isinstance(dim, int):
1669-
checker_throw_value_error("sample", "type(dim)", type(dim), int)
16701553
return dpnp_random(size)
16711554

16721555
return call_origin(numpy.random.sample, size)
@@ -1741,15 +1624,6 @@ def standard_cauchy(size=None):
17411624
"""
17421625

17431626
if not use_origin_backend(size):
1744-
if size is None:
1745-
size = 1
1746-
elif isinstance(size, tuple):
1747-
for dim in size:
1748-
if not isinstance(dim, int):
1749-
checker_throw_value_error("standard_cauchy", "type(dim)", type(dim), int)
1750-
elif not isinstance(size, int):
1751-
checker_throw_value_error("standard_cauchy", "type(size)", type(size), int)
1752-
17531627
return dpnp_standard_cauchy(size)
17541628

17551629
return call_origin(numpy.random.standard_cauchy, size)
@@ -1783,15 +1657,6 @@ def standard_exponential(size=None):
17831657
"""
17841658

17851659
if not use_origin_backend(size):
1786-
if size is None:
1787-
size = 1
1788-
elif isinstance(size, tuple):
1789-
for dim in size:
1790-
if not isinstance(dim, int):
1791-
checker_throw_value_error("standard_exponential", "type(dim)", type(dim), int)
1792-
elif not isinstance(size, int):
1793-
checker_throw_value_error("standard_exponential", "type(size)", type(size), int)
1794-
17951660
return dpnp_standard_exponential(size)
17961661

17971662
return call_origin(numpy.random.standard_exponential, size)
@@ -1851,15 +1716,6 @@ def standard_gamma(shape, size=None):
18511716
# TODO:
18521717
# array_like of floats for and `shape`
18531718
if not use_origin_backend(shape) and dpnp_queue_is_cpu():
1854-
if size is None:
1855-
size = 1
1856-
elif isinstance(size, tuple):
1857-
for dim in size:
1858-
if not isinstance(dim, int):
1859-
checker_throw_value_error("standard_gamma", "type(dim)", type(dim), int)
1860-
elif not isinstance(size, int):
1861-
checker_throw_value_error("standard_gamma", "type(size)", type(size), int)
1862-
18631719
if shape < 0:
18641720
checker_throw_value_error("standard_gamma", "shape", shape, "non-negative")
18651721

@@ -1889,15 +1745,6 @@ def standard_normal(size=None):
18891745
"""
18901746

18911747
if not use_origin_backend(size):
1892-
if size is None:
1893-
size = 1
1894-
elif isinstance(size, tuple):
1895-
for dim in size:
1896-
if not isinstance(dim, int):
1897-
checker_throw_value_error("standard_normal", "type(dim)", type(dim), int)
1898-
elif not isinstance(size, int):
1899-
checker_throw_value_error("standard_normal", "type(size)", type(size), int)
1900-
19011748
return dpnp_standard_normal(size)
19021749

19031750
return call_origin(numpy.random.standard_normal, size)
@@ -1974,8 +1821,6 @@ def uniform(low=0.0, high=1.0, size=None):
19741821
"""
19751822

19761823
if not use_origin_backend(low):
1977-
if size is None:
1978-
size = 1
19791824
if low == high:
19801825
# TODO:
19811826
# currently dparray.full is not implemented
@@ -2060,20 +1905,10 @@ def weibull(a, size=None):
20601905
"""
20611906

20621907
if not use_origin_backend(a):
2063-
if size is None:
2064-
size = 1
2065-
elif isinstance(size, tuple):
2066-
for dim in size:
2067-
if not isinstance(dim, int):
2068-
checker_throw_value_error("weibull", "type(dim)", type(dim), int)
2069-
elif not isinstance(size, int):
2070-
checker_throw_value_error("weibull", "type(size)", type(size), int)
2071-
20721908
# TODO:
20731909
# array_like of floats for `a` params
20741910
if a < 0:
20751911
checker_throw_value_error("weibulla", "a", a, "non-negative")
2076-
20771912
return dpnp_weibull(a, size)
20781913

20791914
return call_origin(numpy.random.weibull, a, size)

0 commit comments

Comments
 (0)