File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -64,3 +64,35 @@ def test_errors():
6464 Delta (dtype = object )
6565 with pytest .raises (ValueError ):
6666 Delta (dtype = 'i8' , astype = object )
67+
68+
69+ # overflow tests
70+ # Note: Before implementing similar test for integer -> integer types, check numpy/numpy#8987.
71+ oveflow_proned_float_float_pairs = [
72+ ('f4' , 'f2' ),
73+ ('f8' , 'f4' ),
74+ ]
75+
76+
77+ def test_oveflow_proned_float_float_encode ():
78+ for dtype , astype in oveflow_proned_float_float_pairs :
79+ codec = Delta (dtype = dtype , astype = astype )
80+ arr = np .array ([0 , np .finfo (astype ).max .astype (dtype ) * 2 ], dtype = dtype )
81+ with pytest .warns (RuntimeWarning , match = r"overflow encountered" ):
82+ codec .encode (arr )
83+
84+
85+ overflow_proned_integer_float_paris = [
86+ ('i4' , 'f2' ),
87+ ('i8' , 'f2' ),
88+ ('u4' , 'f2' ),
89+ ('u8' , 'f2' ),
90+ ]
91+
92+
93+ def test_oveflow_proned_integer_float_encode ():
94+ for dtype , astype in overflow_proned_integer_float_paris :
95+ codec = Delta (dtype = dtype , astype = astype )
96+ arr = np .array ([0 , int (np .rint (np .finfo (astype ).max )) * 2 ], dtype = dtype )
97+ with pytest .warns (RuntimeWarning , match = r"overflow encountered" ):
98+ codec .encode (arr )
You can’t perform that action at this time.
0 commit comments