Skip to content

Commit b57e565

Browse files
Merge pull request #23 from IntelPython/fix-sat-5359
Fix sat 5359
2 parents 780fde9 + 836083e commit b57e565

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

mkl_random/mklrand.pyx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ cdef object vec_disc0_array(irk_state *state, irk_disc0_vec func, object size,
426426
return array
427427

428428
cdef object vec_long_disc0_array(
429-
irk_state *state, irk_disc0_vec_long func,
429+
irk_state *state, irk_disc0_vec_long func,
430430
object size, object lock
431431
):
432432
cdef long *array_data
@@ -1953,7 +1953,7 @@ cdef class RandomState:
19531953
raise ValueError("Fewer non-zero entries in p than size")
19541954
n_uniq = 0
19551955
p = p.copy()
1956-
found = np.zeros(shape, dtype=np.int)
1956+
found = np.zeros(tuple() if shape is None else shape, dtype=np.int64)
19571957
flat_found = found.ravel()
19581958
while n_uniq < size:
19591959
x = self.rand(size - n_uniq)
@@ -5044,7 +5044,7 @@ cdef class RandomState:
50445044
raise ValueError("nbad < 0")
50455045
if np.any(np.less(onsample, 1)):
50465046
raise ValueError("nsample < 1")
5047-
otot = np.add(ongood, onbad);
5047+
otot = np.asarray(np.add(ongood, onbad));
50485048
if np.any(np.less_equal(otot, 0)):
50495049
raise ValueError("Number of balls in each urn should not exceed 2147483647")
50505050
if np.any(np.less(otot,onsample)):
@@ -5250,7 +5250,7 @@ cdef class RandomState:
52505250
[True, True]
52515251
52525252
"""
5253-
from numpy.dual import svd
5253+
from numpy.linalg import svd
52545254

52555255
# Check preconditions on arguments
52565256
mean = np.array(mean)

mkl_random/tests/test_random.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def test_size(self):
126126
(2, 2, 2))
127127

128128
assert_raises(TypeError, rnd.multinomial, 1, p,
129-
np.float(1))
129+
np.float64(1))
130130

131131

132132
class TestSetState_Intel(TestCase):
@@ -185,7 +185,7 @@ class TestRandint_Intel(TestCase):
185185
np.int32, np.uint32, np.int64, np.uint64]
186186

187187
def test_unsupported_type(self):
188-
assert_raises(TypeError, self.rfunc, 1, dtype=np.float)
188+
assert_raises(TypeError, self.rfunc, 1, dtype=np.float64)
189189

190190
def test_bounds_checking(self):
191191
for dt in self.itype:
@@ -215,7 +215,7 @@ def test_in_bounds_fuzz(self):
215215
vals = self.rfunc(2, ubnd, size=2**16, dtype=dt)
216216
assert_(vals.max() < ubnd)
217217
assert_(vals.min() >= 2)
218-
vals = self.rfunc(0, 2, size=2**16, dtype=np.bool)
218+
vals = self.rfunc(0, 2, size=2**16, dtype='bool')
219219
assert_(vals.max() < 2)
220220
assert_(vals.min() >= 0)
221221

@@ -244,14 +244,13 @@ def test_repeatability(self):
244244
val = self.rfunc(0, 6, size=1000, dtype=dt).byteswap()
245245

246246
res = hashlib.md5(val.view(np.int8)).hexdigest()
247-
print("")
248247
assert_(tgt[np.dtype(dt).name] == res)
249248

250249
# bools do not depend on endianess
251250
rnd.seed(1234, brng='MT19937')
252-
val = self.rfunc(0, 2, size=1000, dtype=np.bool).view(np.int8)
251+
val = self.rfunc(0, 2, size=1000, dtype='bool').view(np.int8)
253252
res = hashlib.md5(val).hexdigest()
254-
assert_(tgt[np.dtype(np.bool).name] == res)
253+
assert_(tgt[np.dtype('bool').name] == res)
255254

256255
def test_respect_dtype_singleton(self):
257256
# See gh-7203
@@ -262,9 +261,9 @@ def test_respect_dtype_singleton(self):
262261
sample = self.rfunc(lbnd, ubnd, dtype=dt)
263262
self.assertEqual(sample.dtype, np.dtype(dt))
264263

265-
for dt in (np.bool, np.int, np.long):
266-
lbnd = 0 if dt is np.bool else np.iinfo(dt).min
267-
ubnd = 2 if dt is np.bool else np.iinfo(dt).max + 1
264+
for dt in (bool, int):
265+
lbnd = 0 if dt is bool else np.iinfo(np.dtype(dt)).min
266+
ubnd = 2 if dt is bool else np.iinfo(np.dtype(dt)).max + 1
268267

269268
# gh-7284: Ensure that we get Python data types
270269
sample = self.rfunc(lbnd, ubnd, dtype=dt)
@@ -527,7 +526,7 @@ def test_dirichlet_size(self):
527526
assert_equal(rnd.dirichlet(p, (2, 2)).shape, (2, 2, 2))
528527
assert_equal(rnd.dirichlet(p, np.array((2, 2))).shape, (2, 2, 2))
529528

530-
assert_raises(TypeError, rnd.dirichlet, p, np.float(1))
529+
assert_raises(TypeError, rnd.dirichlet, p, np.float64(1))
531530

532531

533532
def test_exponential(self):

0 commit comments

Comments
 (0)