File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 1
1
"""Test floating point deconstructions and floor methods
2
2
"""
3
3
import sys
4
+ from contextlib import nullcontext
4
5
5
6
import numpy as np
6
7
import pytest
8
+ from packaging .version import Version
7
9
8
10
from ..casting import (
9
11
FloatingError ,
27
29
28
30
LD_INFO = type_info (np .longdouble )
29
31
32
+ FP_OVERFLOW_WARN = Version (np .__version__ ) <= Version ('2.0.0.dev0' )
33
+
30
34
31
35
def dtt2dict (dtt ):
32
36
"""Create info dictionary from numpy type"""
@@ -149,9 +153,14 @@ def test_as_int():
149
153
nexp64 = floor_log2 (type_info (np .float64 )['max' ])
150
154
with np .errstate (over = 'ignore' ):
151
155
val = np .longdouble (2 ** nexp64 ) * 2 # outside float64 range
152
- with pytest .raises (OverflowError ):
156
+ assert val > np .finfo ('float64' ).max
157
+ if FP_OVERFLOW_WARN :
158
+ ctx = pytest .raises (OverflowError )
159
+ else :
160
+ ctx = nullcontext ()
161
+ with ctx :
153
162
as_int (val )
154
- with pytest . raises ( OverflowError ) :
163
+ with ctx :
155
164
as_int (- val )
156
165
157
166
You can’t perform that action at this time.
0 commit comments