julia

run.julia

Low-level Julia execution utilities for running generated Julia code.

This module provides functions for executing Julia code generated by TVBO templates (DifferentialEquations.jl, BifurcationKit.jl, NetworkDynamics.jl) and extracting results back into Python/NumPy.

Uses juliacall (tvbo.adapters.julia) for the Python↔︎Julia bridge, keeping full Julia objects available for interactive inspection.

Functions

Name Description
ensure_packages Ensure Julia packages are installed, installing if missing.
extract_bifurcation_result Extract a bifurcation result from Julia Main.
extract_ode_solution Extract time and state arrays from a Julia ODE/SDE solution.
run_julia_code Execute a block of Julia code in the Main module.
solution_to_dataarray Build an xr.DataArray from a flat Julia ODE solution.

ensure_packages

run.julia.ensure_packages(*packages)

Ensure Julia packages are installed, installing if missing.

Parameters

packages : str Package names to ensure are available.

extract_bifurcation_result

run.julia.extract_bifurcation_result()

Extract a bifurcation result from Julia Main.

Assumes bifurcation_result exists after running a BifurcationKit.jl script.

Returns

object The Julia BifurcationResult proxy.

extract_ode_solution

run.julia.extract_ode_solution()

Extract time and state arrays from a Julia ODE/SDE solution.

Assumes a variable sol exists in Julia Main after running a DifferentialEquations.jl / NetworkDynamics.jl solve.

Returns

t : np.ndarray Time points, shape (n_t,). u : np.ndarray State array, shape (n_states, n_t). sol : object The raw Julia solution proxy for interactive use.

run_julia_code

run.julia.run_julia_code(code, compiled_modules=True)

Execute a block of Julia code in the Main module.

Parameters

code : str Julia source code to evaluate. compiled_modules : bool Passed to get_julia(). Default True to use precompiled packages.

Returns

object The return value of the last Julia expression.

solution_to_dataarray

run.julia.solution_to_dataarray(t, u, sv_names, n_nodes)

Build an xr.DataArray from a flat Julia ODE solution.

Reshapes u from flat (n_states, n_t) into dims (time, variable, node) with named coordinates.

Parameters

t : np.ndarray Time array, shape (n_t,). u : np.ndarray Raw solution, shape (n_nodes * n_sv, n_t). sv_names : list[str] State variable names (length determines n_sv). n_nodes : int Number of nodes.

Returns

xr.DataArray Dims (time, variable, node) with coords.