Opened 5 years ago
Closed 22 months ago
#17790 closed defect (wontfix)
convert not coerce padics symbolic function arguments
Reported by:  rws  Owned by:  

Priority:  major  Milestone:  sageduplicate/invalid/wontfix 
Component:  symbolics  Keywords:  
Cc:  jdemeyer  Merged in:  
Authors:  Ralf Stephan  Reviewers:  
Report Upstream:  N/A  Work issues:  
Branch:  u/rws/builtinfunction_doesn_t_pass_non_sr_coercible_arguments_to_function_code (Commits)  Commit:  e4a30b68bd6d81deb579806d50d5d8f7630a558a 
Dependencies:  Stopgaps: 
Description (last modified by )
This affects authors of function code but shows also in:
sage: binomial(Qp(5)(8),3)  TypeError Traceback (most recent call last) <ipythoninput143da6d5c56db> in <module>() > 1 binomial(Qp(Integer(5))(Integer(8)),Integer(3)) /home/ralf/sage/src/sage/symbolic/function.pyx in sage.symbolic.function.GinacFunction.__call__ (build/cythonized/sage/symbolic/function.cpp:9048)() 842 (0, Integer Ring) 843 """ > 844 res = super(GinacFunction, self).__call__(*args, **kwds) 845 846 # Convert to Integer if the output was of type "int" and any of /home/ralf/sage/src/sage/symbolic/function.pyx in sage.symbolic.function.BuiltinFunction.__call__ (build/cythonized/sage/symbolic/function.cpp:10572)() 991 res = self._evalf_try_(*args) 992 if res is None: > 993 res = super(BuiltinFunction, self).__call__( 994 *args, coerce=coerce, hold=hold) 995 /home/ralf/sage/src/sage/symbolic/function.pyx in sage.symbolic.function.Function.__call__ (build/cythonized/sage/symbolic/function.cpp:6301)() 485 nargs[i] = SR.coerce(carg) 486 except Exception: > 487 raise TypeError, "cannot coerce arguments: %s"%(err) 488 args = nargs 489 else: # coerce == False TypeError: cannot coerce arguments: no canonical coercion from 5adic Field with capped relative precision 20 to Symbolic Ring
test.
Change History (13)
comment:1 Changed 5 years ago by
 Cc jdemeyer added
 Milestone changed from sage6.5 to sage6.6
comment:2 Changed 5 years ago by
 Branch set to u/rws/builtinfunction_doesn_t_pass_non_sr_coercible_arguments_to_function_code
comment:3 Changed 5 years ago by
 Commit set to f6e21137f97771b916ceae7f16a59805af78291f
 Status changed from new to needs_review
 Summary changed from BuiltinFunction doesn't pass nonSRcoercible arguments to function code to convert not coerce padics symbolic function arguments
It was the latter alternative, as there is no coercion. Please review.
New commits:
f6e2113  17790: add padics to the conversion workaround for symbolic function arguments

comment:4 Changed 4 years ago by
 Milestone changed from sage6.6 to sage6.7
 Status changed from needs_review to needs_work
The recent #17852 makes binomial(Qp(2)(9),5)
fail in this branch with TypeError: function did not return a symbolic expression or an element that can be coerced into a symbolic expression
. Reason: rings.arith.binomial
now returns (correctly) 1 + 5 + 2*5^2 + O(5^20)
instead of 56
.
So what should Function
do when self.eval
returns something not coercible?
comment:5 Changed 4 years ago by
@Jeroen, what reason is there in the respective snippet of Function::__call__
l.478491 not to do the following:
nargs = [None]*len(args) for i in range(len(args)): carg = args[i] try: nargs[i] = SR.coerce(carg) except Exception: nargs[i] = SR(carg)
i.e. not throwing at all. I keep needing exceptions like the Qp
of this ticket.
Do we have a fundamental problem here? Why can rings.arith...
handle this differently?
comment:6 Changed 3 years ago by
 Commit changed from f6e21137f97771b916ceae7f16a59805af78291f to 9a29cd1da4d4a7f974ba34c5d981a43802781294
comment:7 Changed 3 years ago by
 Description modified (diff)
comment:8 Changed 3 years ago by
 Milestone changed from sage6.7 to sage7.3
 Status changed from needs_work to needs_review
comment:9 Changed 3 years ago by
 Commit changed from 9a29cd1da4d4a7f974ba34c5d981a43802781294 to e4a30b68bd6d81deb579806d50d5d8f7630a558a
Branch pushed to git repo; I updated commit sha1. New commits:
e4a30b6  Merge branch 'develop' into t/17790/builtinfunction_doesn_t_pass_non_sr_coercible_arguments_to_function_code

comment:10 Changed 3 years ago by
one failing doctest see patchbot report
comment:11 Changed 3 years ago by
 Status changed from needs_review to needs_work
comment:12 Changed 23 months ago by
 Milestone changed from sage7.3 to sageduplicate/invalid/wontfix
 Status changed from needs_work to positive_review
I think this ticket is wontfix because a better solution would be to write a global Python function accepting everything (as in rings.arith...) and dispatch to the symbolic function for symbolic arguments.
In the ticket case just do
sage: from sage.arith.misc import binomial sage: binomial(Qp(5)(8),3) 1 + 5 + 2*5^2 + O(5^20)
comment:13 Changed 22 months ago by
 Resolution set to wontfix
 Status changed from positive_review to closed
So, either it's a problem of padics not being coercible into
SR
(which they should be?), or there should not be coercion but conversion infunction.pyx
.