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

Commit fcd36b8

Browse files
committed
24365: handle nonnumeric integer expressions in floor/ceil
1 parent 0a674fd commit fcd36b8

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/sage/functions/other.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,22 @@ def _eval_(self, x):
423423
8
424424
sage: ceil(x)
425425
ceil(x)
426+
427+
sage: var('x',domain='integer')
428+
x
429+
sage: ceil(x)
430+
x
431+
sage: ceil(factorial(x) + binomial(x^2, x))
432+
binomial(x^2, x) + factorial(x)
433+
sage: ceil(gamma(abs(2*x)+1) * real(x))
434+
x*gamma(2*abs(x) + 1)
435+
sage: forget()
426436
"""
437+
try:
438+
if SR(x).variables() and x.is_integer():
439+
return x
440+
except TypeError:
441+
pass
427442
try:
428443
return x.ceil()
429444
except AttributeError:
@@ -572,7 +587,22 @@ def _eval_(self, x):
572587
7
573588
sage: floor(x)
574589
floor(x)
590+
591+
sage: var('x',domain='integer')
592+
x
593+
sage: floor(x)
594+
x
595+
sage: floor(factorial(x) + binomial(x^2, x))
596+
binomial(x^2, x) + factorial(x)
597+
sage: floor(gamma(abs(2*x)+1) * real(x))
598+
x*gamma(2*abs(x) + 1)
599+
sage: forget()
575600
"""
601+
try:
602+
if SR(x).variables() and x.is_integer():
603+
return x
604+
except TypeError:
605+
pass
576606
try:
577607
return x.floor()
578608
except AttributeError:

0 commit comments

Comments
 (0)