Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit 1de278b

Browse files
committed
Merge branch 'u/rws/doctest_fixed_pynac_runtimeerrors' of trac.sagemath.org:sage into t/18360/sr_matrix__fails_operations_minus_and_mul
* 'u/rws/doctest_fixed_pynac_runtimeerrors' of trac.sagemath.org:sage: 17321: replace bool with assert in doctests Conflicts: src/sage/symbolic/expression.pyx
2 parents 7521a06 + 420af54 commit 1de278b

File tree

1 file changed

+55
-88
lines changed

1 file changed

+55
-88
lines changed

src/sage/symbolic/expression.pyx

Lines changed: 55 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -2273,10 +2273,8 @@ cdef class Expression(CommutativeRingElement):
22732273
False
22742274
sage: SR(1).__nonzero__()
22752275
True
2276-
sage: bool(abs(x))
2277-
True
2278-
sage: bool(x/x - 1)
2279-
False
2276+
sage: assert(abs(x))
2277+
sage: assert(not x/x - 1)
22802278
22812279
This is called by :meth:`is_zero`::
22822280
@@ -2295,67 +2293,41 @@ cdef class Expression(CommutativeRingElement):
22952293
for symbolic relations::
22962294
22972295
sage: x = var('x')
2298-
sage: bool((x-1)^2 == x^2 - 2*x + 1)
2299-
True
2300-
sage: bool(((x-1)^2 == x^2 - 2*x + 1).expand())
2301-
True
2302-
sage: bool(((x-1)^2 == x^2 - 2*x + 3).expand())
2303-
False
2304-
sage: bool(2 + x < 3 + x)
2305-
True
2306-
sage: bool(2 + x < 1 + x)
2307-
False
2308-
sage: bool(2 + x > 1 + x)
2309-
True
2310-
sage: bool(1 + x > 1 + x)
2311-
False
2312-
sage: bool(1 + x >= 1 + x)
2313-
True
2314-
sage: bool(1 + x < 1 + x)
2315-
False
2316-
sage: bool(1 + x <= 1 + x)
2317-
True
2318-
sage: bool(1 + x^2 != 1 + x*x)
2319-
False
2320-
sage: bool(1 + x^2 != 2 + x*x)
2321-
True
2322-
sage: bool(SR(oo) == SR(oo))
2323-
True
2324-
sage: bool(-SR(oo) == SR(oo))
2325-
False
2326-
sage: bool(-SR(oo) != SR(oo))
2327-
True
2296+
sage: assert((x-1)^2 == x^2 - 2*x + 1)
2297+
sage: assert(((x-1)^2 == x^2 - 2*x + 1).expand())
2298+
sage: assert(not ((x-1)^2 == x^2 - 2*x + 3).expand())
2299+
sage: assert(2 + x < 3 + x)
2300+
sage: assert(not 2 + x < 1 + x)
2301+
sage: assert(2 + x > 1 + x)
2302+
sage: assert(not 1 + x > 1 + x)
2303+
sage: assert(1 + x >= 1 + x)
2304+
sage: assert(not 1 + x < 1 + x)
2305+
sage: assert(1 + x <= 1 + x)
2306+
sage: assert(not 1 + x^2 != 1 + x*x)
2307+
sage: assert(1 + x^2 != 2 + x*x)
2308+
sage: assert(SR(oo) == SR(oo))
2309+
sage: assert(not -SR(oo) == SR(oo))
2310+
sage: assert(-SR(oo) != SR(oo))
23282311
23292312
Next, tests to ensure assumptions are correctly used::
23302313
23312314
sage: x, y, z = var('x, y, z')
2332-
sage: assume(x>=y,y>=z,z>=x)
2333-
sage: bool(x==z)
2334-
True
2335-
sage: bool(z<x)
2336-
False
2337-
sage: bool(z>y)
2338-
False
2339-
sage: bool(y==z)
2340-
True
2341-
sage: bool(y<=z)
2342-
True
2315+
sage: assume(x >= y, y >= z, z >= x)
2316+
sage: assert(x == z)
2317+
sage: assert(not z < x)
2318+
sage: assert(not z > y)
2319+
sage: assert(y == z)
2320+
sage: assert(y <= z)
23432321
sage: forget()
2344-
sage: assume(x>=1,x<=1)
2345-
sage: bool(x==1)
2346-
True
2347-
sage: bool(x != 1)
2348-
False
2349-
sage: bool(x>1)
2350-
False
2322+
sage: assume(x >= 1, x <= 1)
2323+
sage: assert(x == 1)
2324+
sage: assert(not x != 1)
2325+
sage: assert(not x > 1)
23512326
sage: forget()
2352-
sage: assume(x>0)
2353-
sage: bool(x==0)
2354-
False
2355-
sage: bool(x != 0)
2356-
True
2357-
sage: bool(x == 1)
2358-
False
2327+
sage: assume(x > 0)
2328+
sage: assert(not x == 0)
2329+
sage: assert(x != 0)
2330+
sage: assert(not x == 1)
23592331
23602332
The following must be true, even though we do not
23612333
know for sure that x is not 1, as symbolic comparisons
@@ -2365,16 +2337,12 @@ cdef class Expression(CommutativeRingElement):
23652337
23662338
::
23672339
2368-
sage: bool(x != 1)
2369-
True
2340+
sage: assert(x != 1)
23702341
sage: forget()
23712342
sage: assume(x>y)
2372-
sage: bool(x==y)
2373-
False
2374-
sage: bool(x != y)
2375-
True
2376-
sage: bool(x != y) # The same comment as above applies here as well
2377-
True
2343+
sage: assert(not x==y)
2344+
sage: assert(x != y)
2345+
sage: assert(x != y) # The same comment as above applies here as well
23782346
sage: forget()
23792347
23802348
Comparisons of infinities::
@@ -2405,30 +2373,29 @@ cdef class Expression(CommutativeRingElement):
24052373
24062374
Check that :trac:`13326` is fixed::
24072375
2408-
sage: bool(log(2)*Infinity == Infinity)
2409-
True
2376+
sage: assert(log(2)*Infinity == Infinity)
24102377
24112378
More checks for comparisons with infinity (see :trac:`12967`)::
24122379
2413-
sage: assert(bool(SR(oo) > 5))
2414-
sage: assert(bool(5 < SR(oo)))
2415-
sage: assert(bool(SR(2) < Infinity))
2416-
sage: assert(bool(pi < Infinity))
2417-
sage: assert(not bool(pi>Infinity))
2418-
sage: assert(bool(2*pi < Infinity))
2419-
sage: assert(bool(SR(pi) < SR(Infinity)))
2420-
sage: assert(bool(sqrt(2) < oo))
2421-
sage: assert(bool(log(2) < oo))
2422-
sage: assert(bool(e < oo))
2423-
sage: assert(bool(e+pi < oo))
2424-
sage: assert(bool(e^pi < oo))
2425-
sage: assert(not bool(SR(2) < -oo))
2426-
sage: assert(bool(SR(2) > -oo))
2427-
sage: assert(bool(exp(2) > -oo))
2428-
sage: assert(bool(SR(oo) > sqrt(2)))
2429-
sage: assert(bool(sqrt(2) < SR(oo)))
2430-
sage: assert(bool(SR(-oo) < sqrt(2)))
2431-
sage: assert(bool(sqrt(2) > SR(-oo)))
2380+
sage: assert(SR(oo) > 5)
2381+
sage: assert(5 < SR(oo))
2382+
sage: assert(SR(2) < Infinity)
2383+
sage: assert(pi < Infinity)
2384+
sage: assert(not pi>Infinity)
2385+
sage: assert(2*pi < Infinity)
2386+
sage: assert(SR(pi) < SR(Infinity))
2387+
sage: assert(sqrt(2) < oo)
2388+
sage: assert(log(2) < oo)
2389+
sage: assert(e < oo)
2390+
sage: assert(e+pi < oo)
2391+
sage: assert(e^pi < oo)
2392+
sage: assert(not SR(2) < -oo)
2393+
sage: assert(SR(2) > -oo)
2394+
sage: assert(exp(2) > -oo)
2395+
sage: assert(SR(oo) > sqrt(2))
2396+
sage: assert(sqrt(2) < SR(oo))
2397+
sage: assert(SR(-oo) < sqrt(2))
2398+
sage: assert(sqrt(2) > SR(-oo))
24322399
24332400
Check that :trac:`18360` is fixed::
24342401

0 commit comments

Comments
 (0)