@@ -165,25 +165,17 @@ def check_fun_data(
165
165
else :
166
166
targ = targfunc (targartempval , axis = axis , ** kwargs )
167
167
168
- try :
169
- res = testfunc (testarval , axis = axis , skipna = skipna , ** kwargs )
168
+ res = testfunc (testarval , axis = axis , skipna = skipna , ** kwargs )
169
+ self .check_results (targ , res , axis , check_dtype = check_dtype )
170
+ if skipna :
171
+ res = testfunc (testarval , axis = axis , ** kwargs )
172
+ self .check_results (targ , res , axis , check_dtype = check_dtype )
173
+ if axis is None :
174
+ res = testfunc (testarval , skipna = skipna , ** kwargs )
175
+ self .check_results (targ , res , axis , check_dtype = check_dtype )
176
+ if skipna and axis is None :
177
+ res = testfunc (testarval , ** kwargs )
170
178
self .check_results (targ , res , axis , check_dtype = check_dtype )
171
- if skipna :
172
- res = testfunc (testarval , axis = axis , ** kwargs )
173
- self .check_results (targ , res , axis , check_dtype = check_dtype )
174
- if axis is None :
175
- res = testfunc (testarval , skipna = skipna , ** kwargs )
176
- self .check_results (targ , res , axis , check_dtype = check_dtype )
177
- if skipna and axis is None :
178
- res = testfunc (testarval , ** kwargs )
179
- self .check_results (targ , res , axis , check_dtype = check_dtype )
180
- except BaseException as exc :
181
- exc .args += (
182
- "axis: {axis} of {of}" .format (axis = axis , of = testarval .ndim - 1 ),
183
- "skipna: {skipna}" .format (skipna = skipna ),
184
- "kwargs: {kwargs}" .format (kwargs = kwargs ),
185
- )
186
- raise
187
179
188
180
if testarval .ndim <= 1 :
189
181
return
@@ -222,23 +214,15 @@ def check_fun(
222
214
testarval = getattr (self , testar )
223
215
targarval = getattr (self , targar )
224
216
targarnanval = getattr (self , targarnan )
225
- try :
226
- self .check_fun_data (
227
- testfunc ,
228
- targfunc ,
229
- testarval ,
230
- targarval ,
231
- targarnanval ,
232
- empty_targfunc = empty_targfunc ,
233
- ** kwargs
234
- )
235
- except BaseException as exc :
236
- exc .args += (
237
- "testar: {testar}" .format (testar = testar ),
238
- "targar: {targar}" .format (targar = targar ),
239
- "targarnan: {targarnan}" .format (targarnan = targarnan ),
240
- )
241
- raise
217
+ self .check_fun_data (
218
+ testfunc ,
219
+ targfunc ,
220
+ testarval ,
221
+ targarval ,
222
+ targarnanval ,
223
+ empty_targfunc = empty_targfunc ,
224
+ ** kwargs
225
+ )
242
226
243
227
def check_funs (
244
228
self ,
@@ -697,23 +681,19 @@ def check_nancomp(self, checkfun, targ0):
697
681
arr_nan_float1 = self .arr_nan_float1
698
682
699
683
while targ0 .ndim :
700
- try :
701
- res0 = checkfun (arr_float , arr_float1 )
702
- tm .assert_almost_equal (targ0 , res0 )
684
+ res0 = checkfun (arr_float , arr_float1 )
685
+ tm .assert_almost_equal (targ0 , res0 )
703
686
704
- if targ0 .ndim > 1 :
705
- targ1 = np .vstack ([targ0 , arr_nan ])
706
- else :
707
- targ1 = np .hstack ([targ0 , arr_nan ])
708
- res1 = checkfun (arr_float_nan , arr_float1_nan )
709
- tm .assert_numpy_array_equal (targ1 , res1 , check_dtype = False )
710
-
711
- targ2 = arr_nan_nan
712
- res2 = checkfun (arr_float_nan , arr_nan_float1 )
713
- tm .assert_numpy_array_equal (targ2 , res2 , check_dtype = False )
714
- except Exception as exc :
715
- exc .args += ("ndim: {arr_float.ndim}" .format (arr_float = arr_float ),)
716
- raise
687
+ if targ0 .ndim > 1 :
688
+ targ1 = np .vstack ([targ0 , arr_nan ])
689
+ else :
690
+ targ1 = np .hstack ([targ0 , arr_nan ])
691
+ res1 = checkfun (arr_float_nan , arr_float1_nan )
692
+ tm .assert_numpy_array_equal (targ1 , res1 , check_dtype = False )
693
+
694
+ targ2 = arr_nan_nan
695
+ res2 = checkfun (arr_float_nan , arr_nan_float1 )
696
+ tm .assert_numpy_array_equal (targ2 , res2 , check_dtype = False )
717
697
718
698
try :
719
699
arr_float = np .take (arr_float , 0 , axis = - 1 )
@@ -753,15 +733,12 @@ def test_nanne(self):
753
733
754
734
def check_bool (self , func , value , correct , * args , ** kwargs ):
755
735
while getattr (value , "ndim" , True ):
756
- try :
757
- res0 = func (value , * args , ** kwargs )
758
- if correct :
759
- assert res0
760
- else :
761
- assert not res0
762
- except BaseException as exc :
763
- exc .args += ("dim: {}" .format (getattr (value , "ndim" , value )),)
764
- raise
736
+ res0 = func (value , * args , ** kwargs )
737
+ if correct :
738
+ assert res0
739
+ else :
740
+ assert not res0
741
+
765
742
if not hasattr (value , "ndim" ):
766
743
break
767
744
try :
@@ -796,21 +773,13 @@ def test__has_infs(self):
796
773
797
774
for arr , correct in pairs :
798
775
val = getattr (self , arr )
799
- try :
800
- self .check_bool (nanops ._has_infs , val , correct )
801
- except BaseException as exc :
802
- exc .args += (arr ,)
803
- raise
776
+ self .check_bool (nanops ._has_infs , val , correct )
804
777
805
778
for arr , correct in pairs_float :
806
779
val = getattr (self , arr )
807
- try :
808
- self .check_bool (nanops ._has_infs , val , correct )
809
- self .check_bool (nanops ._has_infs , val .astype ("f4" ), correct )
810
- self .check_bool (nanops ._has_infs , val .astype ("f2" ), correct )
811
- except BaseException as exc :
812
- exc .args += (arr ,)
813
- raise
780
+ self .check_bool (nanops ._has_infs , val , correct )
781
+ self .check_bool (nanops ._has_infs , val .astype ("f4" ), correct )
782
+ self .check_bool (nanops ._has_infs , val .astype ("f2" ), correct )
814
783
815
784
def test__isfinite (self ):
816
785
pairs = [
@@ -844,21 +813,13 @@ def test__isfinite(self):
844
813
845
814
for arr , correct in pairs :
846
815
val = getattr (self , arr )
847
- try :
848
- self .check_bool (func1 , val , correct )
849
- except BaseException as exc :
850
- exc .args += (arr ,)
851
- raise
816
+ self .check_bool (func1 , val , correct )
852
817
853
818
for arr , correct in pairs_float :
854
819
val = getattr (self , arr )
855
- try :
856
- self .check_bool (func1 , val , correct )
857
- self .check_bool (func1 , val .astype ("f4" ), correct )
858
- self .check_bool (func1 , val .astype ("f2" ), correct )
859
- except BaseException as exc :
860
- exc .args += (arr ,)
861
- raise
820
+ self .check_bool (func1 , val , correct )
821
+ self .check_bool (func1 , val .astype ("f4" ), correct )
822
+ self .check_bool (func1 , val .astype ("f2" ), correct )
862
823
863
824
def test__bn_ok_dtype (self ):
864
825
assert nanops ._bn_ok_dtype (self .arr_float .dtype , "test" )
0 commit comments