From 47ae5d56c2f99ad88cc342cc1cef8d2ec528b30d Mon Sep 17 00:00:00 2001 From: Paul Jonas Jost <70631928+PaulJonasJost@users.noreply.github.com> Date: Wed, 23 Oct 2024 13:50:00 +0200 Subject: [PATCH] Updated PEtab.jl to work with version 3.x (#1489) * Updated Julia version and PEtab.jl version to latest non breaking version * Updated strings and functions. Changed to version 3.x. Slightly adjusted tolerances in a test * removed specified version from petab.jl * remove caching as a test --- .github/workflows/ci.yml | 7 ++----- pypesto/objective/julia/petabJl.py | 16 ++++++++-------- pypesto/objective/julia/petab_jl_importer.py | 2 +- test/julia/test_pyjulia.py | 6 +++++- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b274e2a61..4db56ab55 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -199,17 +199,14 @@ jobs: - name: Install julia uses: julia-actions/setup-julia@v2 with: - version: 1.9 - - - name: Cache Julia - uses: julia-actions/cache@v2 + version: 1.11 - name: Install dependencies run: .github/workflows/install_deps.sh - name: Install PEtabJL dependencies run: > - julia -e 'using Pkg; Pkg.add(Pkg.PackageSpec(;name="PEtab", version="2.5.0")); + julia -e 'using Pkg; Pkg.add("PEtab"); Pkg.add("OrdinaryDiffEq"); Pkg.add("Sundials")' - name: Run tests diff --git a/pypesto/objective/julia/petabJl.py b/pypesto/objective/julia/petabJl.py index 84de76999..f9ddefb22 100644 --- a/pypesto/objective/julia/petabJl.py +++ b/pypesto/objective/julia/petabJl.py @@ -62,10 +62,10 @@ def __init__( self.petab_jl_problem = petab_jl_problem # get functions - fun = self.petab_jl_problem.compute_cost - grad = self.petab_jl_problem.compute_gradient - hess = self.petab_jl_problem.compute_hessian - x_names = np.asarray(self.petab_jl_problem.θ_names) + fun = self.petab_jl_problem.nllh + grad = self.petab_jl_problem.grad + hess = self.petab_jl_problem.hess + x_names = np.asarray(self.petab_jl_problem.xnames) # call the super super super constructor super(JuliaObjective, self).__init__( @@ -105,10 +105,10 @@ def __setstate__(self, state): self.petab_jl_problem = petab_jl_problem # get functions - fun = self.petab_jl_problem.compute_cost - grad = self.petab_jl_problem.compute_gradient - hess = self.petab_jl_problem.compute_hessian - x_names = np.asarray(self.petab_jl_problem.θ_names) + fun = self.petab_jl_problem.nllh + grad = self.petab_jl_problem.grad + hess = self.petab_jl_problem.hess + x_names = np.asarray(self.petab_jl_problem.xnames) # call the super super constructor super(JuliaObjective, self).__init__(fun, grad, hess, x_names) diff --git a/pypesto/objective/julia/petab_jl_importer.py b/pypesto/objective/julia/petab_jl_importer.py index 3d76900b5..b5b0b444e 100644 --- a/pypesto/objective/julia/petab_jl_importer.py +++ b/pypesto/objective/julia/petab_jl_importer.py @@ -309,7 +309,7 @@ def _write_julia_file( f"found at {link_to_options}\n" f"petabProblem = PEtabODEProblem(\n\t" f"petabModel,\n\t" - f"ode_solver=ODESolver({odeSolvOpt_str}),\n\t" + f"odesolver=ODESolver({odeSolvOpt_str}),\n\t" f"gradient_method=:{options['gradient_method']},\n\t" f"hessian_method=:{options['hessian_method']},\n\t" f"sparse_jacobian={options['sparse_jacobian']},\n\t" diff --git a/test/julia/test_pyjulia.py b/test/julia/test_pyjulia.py index dc0abcdef..8325a44e8 100644 --- a/test/julia/test_pyjulia.py +++ b/test/julia/test_pyjulia.py @@ -59,7 +59,11 @@ def test_pyjulia_pipeline(): # check with analytical value p_opt = obj.get("p_opt") - assert np.allclose(result.optimize_result[0].x, p_opt) # noqa: S101 + assert np.allclose( + result.optimize_result[0].x, + p_opt, + atol=1e-6, # noqa: S101 + ) def test_petabJL_interface():