本文整理汇总了Python中sage.symbolic.ring.SR.pi方法的典型用法代码示例。如果您正苦于以下问题:Python SR.pi方法的具体用法?Python SR.pi怎么用?Python SR.pi使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sage.symbolic.ring.SR
的用法示例。
在下文中一共展示了SR.pi方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_comparison
# 需要导入模块: from sage.symbolic.ring import SR [as 别名]
# 或者: from sage.symbolic.ring.SR import pi [as 别名]
def test_comparison(ring):
"""
Check comparison with infinity
INPUT:
- ``ring`` -- a sub-ring of the real numbers
OUTPUT:
Various attempts are made to generate elements of ``ring``. An
assertion is triggered if one of these elements does not compare
correctly with plus/minus infinity.
EXAMPLES::
sage: from sage.rings.infinity import test_comparison
sage: rings = [ZZ, QQ, RR, RealField(200), RDF, RLF, AA, RIF]
sage: for R in rings:
....: print('testing {}'.format(R))
....: test_comparison(R)
testing Integer Ring
testing Rational Field
testing Real Field with 53 bits of precision
testing Real Field with 200 bits of precision
testing Real Double Field
testing Real Lazy Field
testing Algebraic Real Field
testing Real Interval Field with 53 bits of precision
Comparison with number fields does not work::
sage: K.<sqrt3> = NumberField(x^2-3)
sage: (-oo < 1+sqrt3) and (1+sqrt3 < oo) # known bug
False
The symbolic ring handles its own infinities, but answers
``False`` (meaning: cannot decide) already for some very
elementary comparisons::
sage: test_comparison(SR) # known bug
Traceback (most recent call last):
...
AssertionError: testing -1000.0 in Symbolic Ring: id = ...
"""
from sage.symbolic.ring import SR
elements = [-1e3, 99.9999, -SR(2).sqrt(), 0, 1, 3^(-1/3), SR.pi(), 100000]
elements.append(ring.an_element())
elements.extend(ring.some_elements())
for z in elements:
try:
z = ring(z)
except (ValueError, TypeError):
continue # ignore if z is not in ring
msg = 'testing {} in {}: id = {}, {}, {}'.format(z, ring, id(z), id(infinity), id(minus_infinity))
assert minus_infinity < z, msg
assert z > minus_infinity, msg
assert z < infinity, msg
assert infinity > z, msg
assert minus_infinity <= z, msg
assert z >= minus_infinity, msg
assert z <= infinity, msg
assert infinity >= z, msg