How to access NamedTuple from JuliaCall?

background:

Suppose myFunction is a julia function that returns a named tuple.

I’ve been invoking julia_call() on myFunction as follows:

output_list = julia_call("<julia module>.<myFunction>",<myFunction args>,need_return="R") 
Browse[1]> output_list[1]
[[1]]
Julia Object of type NamedTuple{(:thetahat, :Y), Tuple{Matrix{Float64}, Float64}}.
(thetahat = [0.013788374755447646 ...

question

How can I access the named elements of output_list like :Y and :thetahat above?
Please note, numeric index is not an option since myFunction will in general output a collection of varying size

2 Likes

Hello, exactly the same here… have you found a solution ?

EDIT: found a way, but looks ugly:

> eq = julia_call("nash_cp",payoff)
> eq
Julia Object of type NamedTuple{(:status, :equilibrium_strategies, :expected_payoffs), Tuple{MathOptInterface.TerminationStatusCode, Vector{Vector{Float64}}, Vector{Float64}}}.
(status = MathOptInterface.LOCALLY_SOLVED, equilibrium_strategies = [[0.0, 0.9999999887780999], [0.0, 0.9999999887780999]], expected_payoffs = [-1.9999999807790678, -1.9999999807790678])
> julia_call("getindex",eq,julia_call("Symbol","equilibrium_strategies"))
Julia Object of type Vector{Vector{Float64}}.
[[0.0, 0.9999999887780999], [0.0, 0.9999999887780999]]

EDIT2: A bit better:

> equilibrium_strategies = field(eq,"equilibrium_strategies")
> equilibrium_strategies
Julia Object of type Vector{Vector{Float64}}.
[[0.0, 0.9999999887780999], [0.0, 0.9999999887780999]]