@@ -1772,125 +1772,3 @@ def _gap_init_(self) -> str:
1772
1772
infinity : PlusInfinity = InfinityRing .gen (0 )
1773
1773
Infinity : PlusInfinity = infinity
1774
1774
minus_infinity : MinusInfinity = InfinityRing .gen (1 )
1775
-
1776
-
1777
- def check_comparison (ring ):
1778
- """
1779
- Check comparison with infinity.
1780
-
1781
- INPUT:
1782
-
1783
- - ``ring`` -- a sub-ring of the real numbers
1784
-
1785
- OUTPUT:
1786
-
1787
- Various attempts are made to generate elements of ``ring``. An
1788
- assertion is triggered if one of these elements does not compare
1789
- correctly with plus/minus infinity.
1790
-
1791
- EXAMPLES::
1792
-
1793
- sage: from sage.rings.infinity import check_comparison
1794
- sage: rings = [ZZ, QQ, RDF]
1795
- sage: rings += [RR, RealField(200)] # needs sage.rings.real_mpfr
1796
- sage: rings += [RLF, RIF] # needs sage.rings.real_interval_field
1797
- sage: for R in rings:
1798
- ....: print('testing {}'.format(R))
1799
- ....: check_comparison(R)
1800
- testing Integer Ring
1801
- testing Rational Field
1802
- testing Real Double Field...
1803
- sage: check_comparison(AA) # needs sage.rings.number_field
1804
-
1805
- Comparison with number fields does not work::
1806
-
1807
- sage: x = polygen(ZZ, 'x')
1808
- sage: K.<sqrt3> = NumberField(x^2 - 3) # needs sage.rings.number_field
1809
- sage: (-oo < 1 + sqrt3) and (1 + sqrt3 < oo) # known bug # needs sage.rings.number_field
1810
- False
1811
-
1812
- The symbolic ring handles its own infinities, but answers
1813
- ``False`` (meaning: cannot decide) already for some very
1814
- elementary comparisons::
1815
-
1816
- sage: check_comparison(SR) # known bug # needs sage.symbolic
1817
- Traceback (most recent call last):
1818
- ...
1819
- AssertionError: testing -1000.0 in Symbolic Ring: id = ...
1820
- """
1821
-
1822
- from sage .rings .rational_field import QQ
1823
- elements = [- 1e3 , 99.9999 , 0 , 1 , 100000 ]
1824
- try :
1825
- from sage .symbolic .ring import SR
1826
- except ImportError :
1827
- pass
1828
- else :
1829
- elements += [- SR (2 ).sqrt (), SR .pi (), 3 ** (- QQ .one () / 3 )]
1830
- elements .append (ring .an_element ())
1831
- elements .extend (ring .some_elements ())
1832
- for z in elements :
1833
- try :
1834
- z = ring (z )
1835
- except (ValueError , TypeError ):
1836
- continue # ignore if z is not in ring
1837
- msg = 'testing {} in {}: id = {}, {}, {}' .format (z , ring , id (z ), id (infinity ), id (minus_infinity ))
1838
- assert minus_infinity < z , msg
1839
- assert z > minus_infinity , msg
1840
- assert z < infinity , msg
1841
- assert infinity > z , msg
1842
- assert minus_infinity <= z , msg
1843
- assert z >= minus_infinity , msg
1844
- assert z <= infinity , msg
1845
- assert infinity >= z , msg
1846
-
1847
-
1848
- def check_signed_infinity (pos_inf ):
1849
- """
1850
- Test consistency of infinity representations.
1851
-
1852
- There are different possible representations of infinity in
1853
- Sage. These are all consistent with the infinity ring, that is,
1854
- compare with infinity in the expected way. See also :issue:`14045`
1855
-
1856
- INPUT:
1857
-
1858
- - ``pos_inf`` -- a representation of positive infinity
1859
-
1860
- OUTPUT:
1861
-
1862
- An assertion error is raised if the representation is not
1863
- consistent with the infinity ring.
1864
-
1865
- Check that :issue:`14045` is fixed::
1866
-
1867
- sage: InfinityRing(float('+inf'))
1868
- +Infinity
1869
- sage: InfinityRing(float('-inf'))
1870
- -Infinity
1871
- sage: oo > float('+inf')
1872
- False
1873
- sage: oo == float('+inf')
1874
- True
1875
-
1876
- EXAMPLES::
1877
-
1878
- sage: from sage.rings.infinity import check_signed_infinity
1879
- sage: check_signed_infinity(oo)
1880
- sage: check_signed_infinity(float('+inf'))
1881
- sage: check_signed_infinity(RLF(oo)) # needs sage.rings.real_interval_field
1882
- sage: check_signed_infinity(RIF(oo)) # needs sage.rings.real_interval_field
1883
- sage: check_signed_infinity(SR(oo)) # needs sage.symbolic
1884
- """
1885
- msg = f'testing { pos_inf } ({ type (pos_inf )} )'
1886
- assert InfinityRing (pos_inf ) is infinity , msg
1887
- assert InfinityRing (- pos_inf ) is minus_infinity , msg
1888
- assert infinity == pos_inf , msg
1889
- assert not (infinity > pos_inf ), msg
1890
- assert not (infinity < pos_inf ), msg
1891
- assert minus_infinity == - pos_inf , msg
1892
- assert not (minus_infinity > - pos_inf ), msg
1893
- assert not (minus_infinity < - pos_inf ), msg
1894
- assert pos_inf > - pos_inf , msg
1895
- assert infinity > - pos_inf , msg
1896
- assert pos_inf > minus_infinity , msg
0 commit comments