2
2
3
3
from sage .rings .infinity import Infinity , InfinityRing , infinity , minus_infinity
4
4
from sage .rings .integer_ring import ZZ
5
- from sage .rings .number_field .number_field_base import NumberField
5
+ from sage .rings .number_field .number_field import NumberField
6
6
from sage .rings .polynomial .polynomial_ring import polygen
7
7
from sage .rings .qqbar import AA
8
8
from sage .rings .rational_field import QQ
@@ -29,10 +29,11 @@ def generate_elements(ring):
29
29
30
30
31
31
@pytest .mark .parametrize (
32
- ' element' ,
32
+ " element" ,
33
33
[
34
- generate_elements ( ring )
34
+ element
35
35
for ring in [ZZ , QQ , RDF , RR , RealField (200 ), RLF , RIF , AA ]
36
+ for element in generate_elements (ring )
36
37
],
37
38
)
38
39
def test_comparison (element ):
@@ -58,32 +59,32 @@ def test_comparison_number_field():
58
59
Comparison with number fields does not work.
59
60
This is a known bug.
60
61
"""
61
- x = polygen (ZZ , 'x' )
62
- sqrt3 = NumberField (x ** 2 - 3 , ' sqrt3' ).gen ()
62
+ x = polygen (ZZ , "x" )
63
+ sqrt3 = NumberField (x ** 2 - 3 , " sqrt3" ).gen ()
63
64
element = 1 + sqrt3
64
- assert not (minus_infinity < element < infinity )
65
+ with pytest .raises (TypeError ):
66
+ assert not (minus_infinity < element < infinity )
65
67
66
68
67
- @pytest .mark .parametrize ("element" , generate_elements (SR ))
68
- def test_comparison_symbolic_ring (element ):
69
+ def test_comparison_symbolic_ring ():
69
70
"""
70
71
The symbolic ring handles its own infinities, but answers
71
72
``False`` (meaning: cannot decide) already for some very
72
73
elementary comparisons. This is a known bug.
73
74
"""
74
- with pytest . raises ( AssertionError ):
75
- assert minus_infinity < element
76
- assert element > minus_infinity
77
- assert element < infinity
78
- assert infinity > element
79
- assert minus_infinity <= element
80
- assert element >= minus_infinity
81
- assert element <= infinity
82
- assert infinity >= element
75
+ element = SR . an_element ()
76
+ assert not ( minus_infinity < element )
77
+ assert not ( element > minus_infinity )
78
+ assert not ( element < infinity )
79
+ assert not ( infinity > element )
80
+ assert not ( minus_infinity <= element )
81
+ assert not ( element >= minus_infinity )
82
+ assert not ( element <= infinity )
83
+ assert not ( infinity >= element )
83
84
84
85
85
86
@pytest .mark .parametrize (
86
- ' pos_inf' , [infinity , float (' +inf' ), RLF (infinity ), RIF (infinity ), SR (infinity )]
87
+ " pos_inf" , [infinity , float (" +inf" ), RLF (infinity ), RIF (infinity ), SR (infinity )]
87
88
)
88
89
def test_signed_infinity (pos_inf ):
89
90
"""
@@ -107,7 +108,7 @@ def test_signed_infinity(pos_inf):
107
108
108
109
109
110
def test_issue_14045 ():
110
- assert InfinityRing (float (' +inf' )) is infinity
111
- assert InfinityRing (float (' -inf' )) is minus_infinity
112
- assert not (infinity > float (' +inf' ))
113
- assert infinity == float (' +inf' )
111
+ assert InfinityRing (float (" +inf" )) is infinity
112
+ assert InfinityRing (float (" -inf" )) is minus_infinity
113
+ assert not (infinity > float (" +inf" ))
114
+ assert infinity == float (" +inf" )
0 commit comments