Skip to content
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

Updated PEtab.jl to work with version 3.x #1489

Merged
merged 5 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ jobs:
- name: Install julia
uses: julia-actions/setup-julia@v2
with:
version: 1.9
version: 1.11

- name: Cache Julia
uses: julia-actions/cache@v2
Expand All @@ -209,7 +209,7 @@ jobs:

- 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
Expand Down
16 changes: 8 additions & 8 deletions pypesto/objective/julia/petabJl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__(
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pypesto/objective/julia/petab_jl_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 5 additions & 1 deletion test/julia/test_pyjulia.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
Loading