-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can I convert tuple to float in SymPy.jl #517
Comments
So,
The elements are tuples:
Containers require broadcasting, but that requires a Julia container, not a python one.
These can have
That isn't too satisfactory and it seems I need to add a conversion of tuple, as reaching into pyobject is a break-glass-in-emergency thing. Let's leave this open until this approach gets cleaned up. |
Thank you for your response.
…On Sun, 27 Aug 2023, 6:54 pm john verzani, ***@***.***> wrote:
So, a is a FiniteSet, so can be converted first with elements:
b = elements(a) # A Vector{Sym}
The elements are tuples:
julia> first(b).__class__
PyObject <class 'sympy.core.containers.Tuple'>
Containers require broadcasting, but that requires a Julia container, not
a python one.
I see there is no good conversion here, but this does work:
collect(first(b).__pyobject__) # Vector{Any}
These can have N broadcast over them. So, here we go with all at once:
julia> [N.(collect(bᵢ.__pyobject__)) for bᵢ ∈ elements(a)]
3-element Vector{Vector}:
Complex{BigFloat}[0.7192952090072009848438408050041592069918887074777771245787120318824758516910227 - 0.2556787519860036796633816425355184837854725255142855627025224516632691084316739im, 0.8538031939951993434374394633305605286720741950148152502808586454116827655393182 + 0.1704525013240024531089210950236789891903150170095237084683483011088460722877841im]
Complex{BigFloat}[0.7192952090072009848438408050041592069918887074777771245787120318824758516910227 + 0.2556787519860036796633816425355184837854725255142855627025224516632691084316739im, 0.8538031939951993434374394633305605286720741950148152502808586454116827655393182 - 0.1704525013240024531089210950236789891903150170095237084683483011088460722877841im]
BigFloat[7.936409581985598030312318389991681586016222585044445750842575936235048296617972, -3.957606387990398686874878926661121057344148390029630500561717290823365531078636]
That isn't too satisfactory and it seems I need to add a conversion of
tuple, as reaching into *pyobject* is a break-glass-in-emergency thing.
Let's leave this open until this approach gets cleaned up.
—
Reply to this email directly, view it on GitHub
<#517 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AK4NBY5LEHTJUL5F7NJQMALXXN3SZANCNFSM6AAAAAA37XHTPE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
It looks like in the latest version function |
Does |
Yeah, it works. It seems now the type of |
Yeah, that should have happened. Sorry. |
How can I convert the result of the computation below to float in Julia.
using SymPy
@syms x y
a = nonlinsolve([x^2 + y^3 - 1, 2x + 3y - 4], (x, y))
I have tried a.evalf(10) and N(a) but a.evalf returned error while N(a) returned the same a.
The text was updated successfully, but these errors were encountered: