@@ -301,24 +301,6 @@ def check_funs(self, testfunc, targfunc, allow_complex=True,
301
301
allow_complex = allow_complex )
302
302
self .check_fun (testfunc , targfunc , 'arr_obj' , ** kwargs )
303
303
304
- def check_funs_ddof (self ,
305
- testfunc ,
306
- targfunc ,
307
- allow_complex = True ,
308
- allow_all_nan = True ,
309
- allow_str = True ,
310
- allow_date = False ,
311
- allow_tdelta = False ,
312
- allow_obj = True , ):
313
- for ddof in range (3 ):
314
- try :
315
- self .check_funs (testfunc , targfunc , allow_complex ,
316
- allow_all_nan , allow_str , allow_date ,
317
- allow_tdelta , allow_obj , ddof = ddof )
318
- except BaseException as exc :
319
- exc .args += ('ddof %s' % ddof , )
320
- raise
321
-
322
304
def _badobj_wrap (self , value , func , allow_complex = True , ** kwargs ):
323
305
if value .dtype .kind == 'O' :
324
306
if allow_complex :
@@ -381,37 +363,46 @@ def test_nanmedian(self):
381
363
allow_str = False , allow_date = False ,
382
364
allow_tdelta = True , allow_obj = 'convert' )
383
365
384
- def test_nanvar (self ):
385
- self .check_funs_ddof (nanops .nanvar , np .var , allow_complex = False ,
386
- allow_str = False , allow_date = False ,
387
- allow_tdelta = True , allow_obj = 'convert' )
366
+ @pytest .mark .parametrize ('ddof' , range (3 ))
367
+ def test_nanvar (self , ddof ):
368
+ self .check_funs (nanops .nanvar , np .var , allow_complex = False ,
369
+ allow_str = False , allow_date = False ,
370
+ allow_tdelta = True , allow_obj = 'convert' , ddof = ddof )
388
371
389
- def test_nanstd (self ):
390
- self .check_funs_ddof (nanops .nanstd , np .std , allow_complex = False ,
391
- allow_str = False , allow_date = False ,
392
- allow_tdelta = True , allow_obj = 'convert' )
372
+ @pytest .mark .parametrize ('ddof' , range (3 ))
373
+ def test_nanstd (self , ddof ):
374
+ self .check_funs (nanops .nanstd , np .std , allow_complex = False ,
375
+ allow_str = False , allow_date = False ,
376
+ allow_tdelta = True , allow_obj = 'convert' , ddof = ddof )
393
377
394
378
@td .skip_if_no ('scipy' , min_version = '0.17.0' )
395
- def test_nansem (self ):
379
+ @pytest .mark .parametrize ('ddof' , range (3 ))
380
+ def test_nansem (self , ddof ):
396
381
from scipy .stats import sem
397
382
with np .errstate (invalid = 'ignore' ):
398
- self .check_funs_ddof (nanops .nansem , sem , allow_complex = False ,
399
- allow_str = False , allow_date = False ,
400
- allow_tdelta = False , allow_obj = 'convert' )
383
+ self .check_funs (nanops .nansem , sem , allow_complex = False ,
384
+ allow_str = False , allow_date = False ,
385
+ allow_tdelta = False , allow_obj = 'convert' , ddof = ddof )
401
386
402
387
def _minmax_wrap (self , value , axis = None , func = None ):
388
+
389
+ # numpy warns if all nan
403
390
res = func (value , axis )
404
391
if res .dtype .kind == 'm' :
405
392
res = np .atleast_1d (res )
406
393
return res
407
394
408
395
def test_nanmin (self ):
409
- func = partial (self ._minmax_wrap , func = np .min )
410
- self .check_funs (nanops .nanmin , func , allow_str = False , allow_obj = False )
396
+ with warnings .catch_warnings (record = True ):
397
+ func = partial (self ._minmax_wrap , func = np .min )
398
+ self .check_funs (nanops .nanmin , func ,
399
+ allow_str = False , allow_obj = False )
411
400
412
401
def test_nanmax (self ):
413
- func = partial (self ._minmax_wrap , func = np .max )
414
- self .check_funs (nanops .nanmax , func , allow_str = False , allow_obj = False )
402
+ with warnings .catch_warnings (record = True ):
403
+ func = partial (self ._minmax_wrap , func = np .max )
404
+ self .check_funs (nanops .nanmax , func ,
405
+ allow_str = False , allow_obj = False )
415
406
416
407
def _argminmax_wrap (self , value , axis = None , func = None ):
417
408
res = func (value , axis )
@@ -425,17 +416,15 @@ def _argminmax_wrap(self, value, axis=None, func=None):
425
416
return res
426
417
427
418
def test_nanargmax (self ):
428
- func = partial (self ._argminmax_wrap , func = np .argmax )
429
- self .check_funs (nanops .nanargmax , func , allow_str = False ,
430
- allow_obj = False , allow_date = True , allow_tdelta = True )
419
+ with warnings .catch_warnings (record = True ):
420
+ func = partial (self ._argminmax_wrap , func = np .argmax )
421
+ self .check_funs (nanops .nanargmax , func ,
422
+ allow_str = False , allow_obj = False ,
423
+ allow_date = True , allow_tdelta = True )
431
424
432
425
def test_nanargmin (self ):
433
- func = partial (self ._argminmax_wrap , func = np .argmin )
434
- if tm .sys .version_info [0 :2 ] == (2 , 6 ):
435
- self .check_funs (nanops .nanargmin , func , allow_date = True ,
436
- allow_tdelta = True , allow_str = False ,
437
- allow_obj = False )
438
- else :
426
+ with warnings .catch_warnings (record = True ):
427
+ func = partial (self ._argminmax_wrap , func = np .argmin )
439
428
self .check_funs (nanops .nanargmin , func , allow_str = False ,
440
429
allow_obj = False )
441
430
0 commit comments