Opened 2 years ago
Last modified 7 days ago
#31282 new defect
Allow to take the sign of a callable symbolic expression
Reported by: | rburing | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | |
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 (12)
comment:1 Changed 2 years ago by
comment:2 follow-up: 3 Changed 2 years ago by
Owner: | set 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 Changed 2 years 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 2 years 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 23 months ago by
Milestone: | sage-9.3 → 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 22 months ago by
Owner: | gh-bmlivin deleted |
---|
comment:7 Changed 19 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 18 months ago by
Milestone: | sage-9.4 → sage-9.5 |
---|
comment:9 Changed 14 months ago by
Milestone: | sage-9.5 → sage-9.6 |
---|
comment:10 Changed 10 months ago by
Milestone: | sage-9.6 → sage-9.7 |
---|
comment:11 Changed 5 months ago by
Milestone: | sage-9.7 → sage-9.8 |
---|
comment:12 Changed 7 days ago by
Milestone: | sage-9.8 |
---|
Moreover, one can build the object in sage