@@ -301,24 +301,6 @@ def check_funs(self, testfunc, targfunc, allow_complex=True,
301301 allow_complex = allow_complex )
302302 self .check_fun (testfunc , targfunc , 'arr_obj' , ** kwargs )
303303
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-
322304 def _badobj_wrap (self , value , func , allow_complex = True , ** kwargs ):
323305 if value .dtype .kind == 'O' :
324306 if allow_complex :
@@ -381,37 +363,46 @@ def test_nanmedian(self):
381363 allow_str = False , allow_date = False ,
382364 allow_tdelta = True , allow_obj = 'convert' )
383365
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 )
388371
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 )
393377
394378 @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 ):
396381 from scipy .stats import sem
397382 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 )
401386
402387 def _minmax_wrap (self , value , axis = None , func = None ):
388+
389+ # numpy warns if all nan
403390 res = func (value , axis )
404391 if res .dtype .kind == 'm' :
405392 res = np .atleast_1d (res )
406393 return res
407394
408395 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 )
411400
412401 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 )
415406
416407 def _argminmax_wrap (self , value , axis = None , func = None ):
417408 res = func (value , axis )
@@ -425,17 +416,15 @@ def _argminmax_wrap(self, value, axis=None, func=None):
425416 return res
426417
427418 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 )
431424
432425 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 )
439428 self .check_funs (nanops .nanargmin , func , allow_str = False ,
440429 allow_obj = False )
441430
0 commit comments