Opened 8 months ago
Last modified 4 weeks ago
#31282 new defect
Allow to take the sign of a callable symbolic expression
Reported by: | rburing | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | sage-9.5 |
Component: | symbolics | Keywords: | sign, callablesymbolicexpression |
Cc: | gh-DaveWitteMorris | Merged in: | |
Authors: | Reviewers: | ||
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
Reported in Ask SageMath question #55417:
sage: f(x) = x^2 sage: cos(f) x |--> cos(x^2) sage: log(f) x |--> log(x^2) sage: sign(x^2) sgn(x^2) sage: sign(f) ... TypeError: cannot coerce arguments: no canonical coercion from Callable function ring with argument x to Symbolic Ring
Change History (8)
comment:1 Changed 8 months ago by
comment:2 follow-up: ↓ 3 Changed 8 months ago by
- Owner changed from (none) to gh-bmlivin
I think this can be fixed by renaming the sage.symbolics.expression.Expression.csgn
method to sgn
and giving it the @property
decorator. I'm going to test that out and see if it breaks anything.
comment:3 in reply to: ↑ 2 Changed 8 months ago by
Replying to gh-bmlivin:
I think this can be fixed by renaming the
sage.symbolics.expression.Expression.csgn
method tosgn
and giving it the@property
decorator. I'm going to test that out and see if it breaks anything.
Never mind. That broke a number of tests, and it doesn't appear to do what it should anyway. I will continue to look for other ways to do this.
comment:4 Changed 8 months ago by
So I've attempted to make a sage.symbolic.expression.Expression.sgn
method which returns giac.sgn(self)
. This causes one of the tests in src.sage.symbolic.expression
to fail:
sage: unicode_art(SR(1.3 - I))
should return 1.3 - ⅈ
, but it instead returns 1.3 - 1.0⋅ⅈ
. I'm not sure whether this really matters, especially since there are other tests in that same method which return 1.0⋅x
instead of x
, but is a test that technically fails.
I have a feeling there may some other formatting tests that this may cause to fail, and I'm not sure why.
comment:5 Changed 6 months ago by
- Milestone changed from sage-9.3 to sage-9.4
Sage development has entered the release candidate phase for 9.3. Setting a new milestone for this ticket based on a cursory review of ticket status, priority, and last modification date.
comment:6 Changed 5 months ago by
- Owner changed from gh-bmlivin to (none)
comment:7 Changed 3 months ago by
- Cc gh-DaveWitteMorris added
By the docstring, FunctionSignum
seems intended to be used for real inputs only. But the various conversions also work for complex input. What's missing is a conversion to pynac's csgn
(FunctionSignum
is a BuiltinFunction
, not a GinacFunction
, for a reason unknown to me). Fixing this will likely also fix the issue on the ticket description.
comment:8 Changed 4 weeks ago by
- Milestone changed from sage-9.4 to sage-9.5
Moreover, one can build the object in sage