Skip to content

Commit

Permalink
Adhere to new petabl.jl 2.0 version syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulJonasJost committed Oct 10, 2023
1 parent d28fa0e commit beb8b9e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 21 deletions.
11 changes: 5 additions & 6 deletions doc/example/conversion_reaction/PEtabJl_module.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ using Sundials
using PEtab

pathYaml = "/Users/pauljonasjost/Documents/GitHub_Folders/pyPESTO/test/julia/../../doc/example/conversion_reaction/conversion_reaction.yaml"
petabModel = readPEtabModel(pathYaml, verbose=true)
petabModel = PEtabModel(pathYaml, verbose=true)

# A full list of options for createPEtabODEProblem can be found at https://sebapersson.github.io/PEtab.jl/dev/API_choosen/#PEtab.setupPEtabODEProblem
petabProblem = createPEtabODEProblem(
petabProblem = PEtabODEProblem(
petabModel,
odeSolverOptions=ODESolverOptions(Rodas5P(), abstol=1e-08, reltol=1e-08, maxiters=Int64(1e4)),
gradientMethod=:ForwardDiff,
hessianMethod=:ForwardDiff,
sparseJacobian=nothing,
ode_solver=ODESolver(Rodas5P(), abstol=1e-08, reltol=1e-08, maxiters=Int64(1e4)),
gradient_method=:ForwardDiff,
hessian_method=:ForwardDiff,
verbose=true
)

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 @@ -61,10 +61,10 @@ def __init__(
self.petab_jl_problem = petab_jl_problem

# get functions
fun = self.petab_jl_problem.computeCost
grad = self.petab_jl_problem.computeGradient
hess = self.petab_jl_problem.computeHessian
x_names = np.asarray(self.petab_jl_problem.θ_estNames)
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)

# call the super super super constructor
super(JuliaObjective, self).__init__(
Expand Down Expand Up @@ -102,10 +102,10 @@ def __setstate__(self, state):
self.petab_jl_problem = petab_jl_problem

# get functions
fun = self.petab_jl_problem.computeCost
grad = self.petab_jl_problem.computeGradient
hess = self.petab_jl_problem.computeHessian
x_names = np.asarray(self.petab_jl_problem.θ_estNames)
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)

# call the super super constructor
super(JuliaObjective, self).__init__(fun, grad, hess, x_names)
Expand Down
13 changes: 6 additions & 7 deletions pypesto/objective/julia/petab_jl_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,15 +304,14 @@ def _write_julia_file(
f"using Sundials\n"
f"using PEtab\n\n"
f"pathYaml = \"{yaml_file}\"\n"
f"petabModel = readPEtabModel(pathYaml, verbose=true)\n\n"
f"# A full list of options for createPEtabODEProblem can be "
f"petabModel = PEtabModel(pathYaml, verbose=true)\n\n"
f"# A full list of options for PEtabODEProblem can be "
f"found at {link_to_options}\n"
f"petabProblem = createPEtabODEProblem(\n\t"
f"petabProblem = PEtabODEProblem(\n\t"
f"petabModel,\n\t"
f"odeSolverOptions=ODESolverOptions({odeSolvOpt_str}),\n\t"
f"gradientMethod=:{options['gradientMethod']},\n\t"
f"hessianMethod=:{options['hessianMethod']},\n\t"
f"sparseJacobian={options['sparseJacobian']},\n\t"
f"ode_solver=ODESolver({odeSolvOpt_str}),\n\t"
f"gradient_method=:{options['gradientMethod']},\n\t"
f"hessian_method=:{options['hessianMethod']},\n\t"
f"verbose={options['verbose']}\n)\n\nend\n"
)
# write file
Expand Down

0 comments on commit beb8b9e

Please sign in to comment.