Skip to content

Commit

Permalink
Merge branch 'develop' into update_julia_objective
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulJonasJost authored Oct 23, 2024
2 parents 251299f + 47ae5d5 commit d0f7ff0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
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

0 comments on commit d0f7ff0

Please sign in to comment.