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 11"""Test floating point deconstructions and floor methods
22"""
33import sys
4+ from contextlib import nullcontext
45
56import numpy as np
67import pytest
8+ from packaging .version import Version
79
810from ..casting import (
911 FloatingError ,
2729
2830LD_INFO = type_info (np .longdouble )
2931
32+ FP_OVERFLOW_WARN = Version (np .__version__ ) <= Version ('2.0.0.dev0' )
33+
3034
3135def dtt2dict (dtt ):
3236 """Create info dictionary from numpy type"""
@@ -149,9 +153,14 @@ def test_as_int():
149153 nexp64 = floor_log2 (type_info (np .float64 )['max' ])
150154 with np .errstate (over = 'ignore' ):
151155 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 :
153162 as_int (val )
154- with pytest . raises ( OverflowError ) :
163+ with ctx :
155164 as_int (- val )
156165
157166
You can’t perform that action at this time.
0 commit comments