Opened 8 years ago
Closed 7 years ago
#14850 closed defect (duplicate)
Arithmetic operators extracted from expressions do not support holding
Reported by: | eviatarbach | Owned by: | burcin |
---|---|---|---|
Priority: | major | Milestone: | sage-duplicate/invalid/wontfix |
Component: | symbolics | Keywords: | |
Cc: | Merged in: | ||
Authors: | Reviewers: | Burcin Erocal | |
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
The fact that calling .operator()
on symbolic expressions with arithmetic operations returns a function that does not support holding means that a held expression cannot be properly reconstructed:
sage: a = x.add(x, hold=True) sage: a x + x sage: a.operator()(x, x) 2*x sage: a.operator()(x, x, hold=True) ... TypeError: add() takes no keyword arguments
This causes problems for #10034.
Change History (5)
comment:1 Changed 8 years ago by
comment:2 follow-up: ↓ 3 Changed 8 years ago by
I suppose, although that one is a fairly broad ticket. Maybe this one should just be dedicated to fixing the arithmetic operators?
Another problem is that the operators in the operator
module only accept two arguments, which is a major problem, since there is no way to reliably reconstruct expressions such as x + 3 + y
.
comment:3 in reply to: ↑ 2 Changed 8 years ago by
- Milestone changed from sage-5.12 to sage-duplicate/invalid/wontfix
- Reviewers set to Burcin Erocal
- Status changed from new to needs_review
Replying to eviatarbach:
I suppose, although that one is a fairly broad ticket. Maybe this one should just be dedicated to fixing the arithmetic operators?
Another problem is that the operators in the
operator
module only accept two arguments, which is a major problem, since there is no way to reliably reconstruct expressions such asx + 3 + y
.
This is exactly item 2 in what Simon requests in #10169. I described how I think it should be fixed in comment:1.
I don't think we should have an identity operator which is returned instead of None
for var('x').operator()
. So this leaves only item 2 in #10169, which is identical to this ticket. Other cases where ex.operator()(*ex.operands())
do not hold should get their own ticket, like #10136.
comment:4 Changed 7 years ago by
- Status changed from needs_review to positive_review
comment:5 Changed 7 years ago by
- Resolution set to duplicate
- Status changed from positive_review to closed
Isn't this a duplicate of #10169?
We should create a module
sage.symbolic.operator
, and override functions defined in Pythonsoperator
module with others, which take multiple arguments when appropriate and support a hold argument if you like. Hopefully this can be done by wrapping the existing functions defined inoperator
with minimum code duplication and speed penalty.