1

I am trying to use as_coefficients_dict (a python) function in Julia 1.7.1 but getting the error below:

The error occurs in the below code in the last line where I have
S = [p0].as_coefficients_dict().keys(). See the code below:

p0 = sympify(dense_interpolation([a[1]] .+ r, [p0] .+ P).subs(Symbol('x'), x_var[1]))
S = [p0].as_coefficients_dict().keys()

as_coefficients_dict() is a python function. How to represent it in Julia?
Could anyone help me out?

martineau
  • 119,623
  • 25
  • 170
  • 301
Ashraf Yawar
  • 857
  • 1
  • 7
  • 15
  • Likely you need to make your object a Poly instance first. – jverzani Jan 23 '22 at 01:52
  • i tried it, didn't work, the problem is : can we represent the as_coefficients_dict() in julia, if there is any way, it would be great if you mention it :) – Ashraf Yawar Jan 23 '22 at 02:06
  • I’m not at my computer, so can’t get you a working example, but using coeffs(ex, var) form to pull out the coefficient of the monomial var could be used. An example in python that could be modified is here https://stackoverflow.com/questions/22955888/how-to-extract-all-coefficients-in-sympy – jverzani Jan 23 '22 at 13:25
  • It is unclear to me why you are calling `[p0].as_coefficients_dict` as opposed to `p0.as_coefficients_dict`; if this is Julia syntax, then this would appear to be wrapping `p0` in an array, which could not possibly have `as_coefficients_dict` as a field – cbk Jan 23 '22 at 17:23

0 Answers0