@@ -299,6 +299,53 @@ def test_datetime(self):
299
299
assert_equal (d_edge .dtype , dates .dtype )
300
300
assert_equal (t_edge .dtype , td )
301
301
302
+ def do_precision_lower_bound (self , float_small , float_large ):
303
+ eps = np .finfo (float_large ).eps
304
+
305
+ arr = np .array ([1.0 ], float_small )
306
+ range = np .array ([1.0 + eps , 2.0 ], float_large )
307
+
308
+ # test is looking for behavior when the bounds change between dtypes
309
+ if range .astype (float_small )[0 ] != 1 :
310
+ return
311
+
312
+ # previously crashed
313
+ count , x_loc = np .histogram (arr , bins = 1 , range = range )
314
+ assert_equal (count , [1 ])
315
+
316
+ # gh-10322 means that the type comes from arr - this may change
317
+ assert_equal (x_loc .dtype , float_small )
318
+
319
+ def do_precision_upper_bound (self , float_small , float_large ):
320
+ eps = np .finfo (float_large ).eps
321
+
322
+ arr = np .array ([1.0 ], float_small )
323
+ range = np .array ([0.0 , 1.0 - eps ], float_large )
324
+
325
+ # test is looking for behavior when the bounds change between dtypes
326
+ if range .astype (float_small )[- 1 ] != 1 :
327
+ return
328
+
329
+ # previously crashed
330
+ count , x_loc = np .histogram (arr , bins = 1 , range = range )
331
+ assert_equal (count , [1 ])
332
+
333
+ # gh-10322 means that the type comes from arr - this may change
334
+ assert_equal (x_loc .dtype , float_small )
335
+
336
+ def do_precision (self , float_small , float_large ):
337
+ self .do_precision_lower_bound (float_small , float_large )
338
+ self .do_precision_upper_bound (float_small , float_large )
339
+
340
+ def test_precision (self ):
341
+ # not looping results in a useful stack trace upon failure
342
+ self .do_precision (np .half , np .single )
343
+ self .do_precision (np .half , np .double )
344
+ self .do_precision (np .half , np .longdouble )
345
+ self .do_precision (np .single , np .double )
346
+ self .do_precision (np .single , np .longdouble )
347
+ self .do_precision (np .double , np .longdouble )
348
+
302
349
303
350
class TestHistogramOptimBinNums (object ):
304
351
"""
0 commit comments