@@ -85,7 +85,7 @@ def test_size(self):
85
85
(2 , 2 , 2 ))
86
86
87
87
assert_raises (TypeError , mt19937 .multinomial , 1 , p ,
88
- np . float (1 ))
88
+ float (1 ))
89
89
90
90
91
91
class TestSetState (TestCase ):
@@ -141,25 +141,25 @@ class TestRandint(TestCase):
141
141
rfunc = random .randint
142
142
143
143
# valid integer/boolean types
144
- itype = [np . bool_ , np .int8 , np .uint8 , np .int16 , np .uint16 ,
144
+ itype = [bool , np .int8 , np .uint8 , np .int16 , np .uint16 ,
145
145
np .int32 , np .uint32 , np .int64 , np .uint64 ]
146
146
147
147
def test_unsupported_type (self ):
148
- assert_raises (TypeError , self .rfunc , 1 , dtype = np . float )
148
+ assert_raises (TypeError , self .rfunc , 1 , dtype = float )
149
149
150
150
def test_bounds_checking (self ):
151
151
for dt in self .itype :
152
- lbnd = 0 if dt is np . bool_ else np .iinfo (dt ).min
153
- ubnd = 2 if dt is np . bool_ else np .iinfo (dt ).max + 1
152
+ lbnd = 0 if dt is bool else np .iinfo (dt ).min
153
+ ubnd = 2 if dt is bool else np .iinfo (dt ).max + 1
154
154
assert_raises (ValueError , self .rfunc , lbnd - 1 , ubnd , dtype = dt )
155
155
assert_raises (ValueError , self .rfunc , lbnd , ubnd + 1 , dtype = dt )
156
156
assert_raises (ValueError , self .rfunc , ubnd , lbnd , dtype = dt )
157
157
assert_raises (ValueError , self .rfunc , 1 , 0 , dtype = dt )
158
158
159
159
def test_rng_zero_and_extremes (self ):
160
160
for dt in self .itype :
161
- lbnd = 0 if dt is np . bool_ else np .iinfo (dt ).min
162
- ubnd = 2 if dt is np . bool_ else np .iinfo (dt ).max + 1
161
+ lbnd = 0 if dt is bool else np .iinfo (dt ).min
162
+ ubnd = 2 if dt is bool else np .iinfo (dt ).max + 1
163
163
164
164
tgt = ubnd - 1
165
165
assert_equal (self .rfunc (tgt , tgt + 1 , size = 1000 , dtype = dt ), tgt )
@@ -174,8 +174,8 @@ def test_full_range(self):
174
174
# Test for ticket #1690
175
175
176
176
for dt in self .itype :
177
- lbnd = 0 if dt is np . bool_ else np .iinfo (dt ).min
178
- ubnd = 2 if dt is np . bool_ else np .iinfo (dt ).max + 1
177
+ lbnd = 0 if dt is bool else np .iinfo (dt ).min
178
+ ubnd = 2 if dt is bool else np .iinfo (dt ).max + 1
179
179
180
180
try :
181
181
self .rfunc (lbnd , ubnd , dtype = dt )
@@ -194,15 +194,15 @@ def test_in_bounds_fuzz(self):
194
194
assert_ (vals .max () < ubnd )
195
195
assert_ (vals .min () >= 2 )
196
196
197
- vals = self .rfunc (0 , 2 , size = 2 ** 16 , dtype = np . bool_ )
197
+ vals = self .rfunc (0 , 2 , size = 2 ** 16 , dtype = bool )
198
198
199
199
assert_ (vals .max () < 2 )
200
200
assert_ (vals .min () >= 0 )
201
201
202
202
def test_repeatability (self ):
203
203
import hashlib
204
204
# We use a md5 hash of generated sequences of 1000 samples
205
- # in the range [0, 6) for all but np. bool, where the range
205
+ # in the range [0, 6) for all but bool, where the range
206
206
# is [0, 2). Hashes are for little endian numbers.
207
207
tgt = {'bool' : '7dd3170d7aa461d201a65f8bcf3944b0' ,
208
208
'int16' : '1b7741b80964bb190c50d541dca1cac1' ,
@@ -228,9 +228,9 @@ def test_repeatability(self):
228
228
229
229
# bools do not depend on endianess
230
230
mt19937 .seed (1234 )
231
- val = self .rfunc (0 , 2 , size = 1000 , dtype = np . bool ).view (np .int8 )
231
+ val = self .rfunc (0 , 2 , size = 1000 , dtype = bool ).view (np .int8 )
232
232
res = hashlib .md5 (val ).hexdigest ()
233
- assert_ (tgt [np .dtype (np . bool ).name ] == res )
233
+ assert_ (tgt [np .dtype (bool ).name ] == res )
234
234
235
235
def test_int64_uint64_corner_case (self ):
236
236
# When stored in Numpy arrays, `lbnd` is casted
@@ -258,15 +258,16 @@ def test_int64_uint64_corner_case(self):
258
258
def test_respect_dtype_singleton (self ):
259
259
# See gh-7203
260
260
for dt in self .itype :
261
- lbnd = 0 if dt is np .bool_ else np .iinfo (dt ).min
262
- ubnd = 2 if dt is np .bool_ else np .iinfo (dt ).max + 1
261
+ lbnd = 0 if dt is bool else np .iinfo (dt ).min
262
+ ubnd = 2 if dt is bool else np .iinfo (dt ).max + 1
263
+ dt = np .bool_ if dt is bool else dt
263
264
264
265
sample = self .rfunc (lbnd , ubnd , dtype = dt )
265
- self .assertEqual (sample .dtype , np . dtype ( dt ) )
266
+ self .assertEqual (sample .dtype , dt )
266
267
267
- for dt in (np . bool , np . int , np .long ):
268
- lbnd = 0 if dt is np . bool else np .iinfo (dt ).min
269
- ubnd = 2 if dt is np . bool else np .iinfo (dt ).max + 1
268
+ for dt in (bool , int , np .long ):
269
+ lbnd = 0 if dt is bool else np .iinfo (dt ).min
270
+ ubnd = 2 if dt is bool else np .iinfo (dt ).max + 1
270
271
271
272
# gh-7284: Ensure that we get Python data types
272
273
sample = self .rfunc (lbnd , ubnd , dtype = dt )
@@ -527,7 +528,7 @@ def test_dirichlet_size(self):
527
528
assert_equal (mt19937 .dirichlet (p , (2 , 2 )).shape , (2 , 2 , 2 ))
528
529
assert_equal (mt19937 .dirichlet (p , np .array ((2 , 2 ))).shape , (2 , 2 , 2 ))
529
530
530
- assert_raises (TypeError , mt19937 .dirichlet , p , np . float (1 ))
531
+ assert_raises (TypeError , mt19937 .dirichlet , p , float (1 ))
531
532
532
533
def test_exponential (self ):
533
534
mt19937 .seed (self .seed )
0 commit comments