# Debugging diffeqpy code, remake not defined

**URL:** <https://discourse.julialang.org/t/debugging-diffeqpy-code-remake-not-defined/40421>\
**Category:** General Usage\
**Tags:** diffeq, debugging, sde\
**Created:** [May 29, 2020, 3:31pm UTC](https://discourse.julialang.org/t/debugging-diffeqpy-code-remake-not-defined/40421 "2020-05-29T15:31:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abolfazl\_Ziaeemehr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abolfazl_ziaeemehr/32/9014_2.png) [@Abolfazl\_Ziaeemehr](https://discourse.julialang.org/u/Abolfazl_Ziaeemehr)\
**Post date:** [May 29, 2020, 3:31pm UTC](https://discourse.julialang.org/t/debugging-diffeqpy-code-remake-not-defined/40421/1 "2020-05-29T15:31:36Z")

</div>

I am going to solve a system of SDE using diffeqpy and use `EnsembleProblem`.  
I don’t know why I am getting `remake not defined error`.

The code run properly without `EnsembleProblem`.  
So I guess the problem should be in `prob_func`, but what is that?

Here is the script:

```julia
import numpy as np
import pylab as pl
from math import pi
from time import time
from sys import exit

try:
    from diffeqpy import de
    from julia import Main
except:
    from julia.api import Julia
    jl = Julia(compiled_modules=False)
    from julia import Main
    from diffeqpy import de

julia_f = Main.eval("""
function f!(du, u, p, t)
    
    for i = 1:p[1]
        du[i] = 2.0 + sum(sin.(u .- u[i]))
    end
    return du
end
""" )

julia_g = Main.eval("""
function g!(du, u, p, t)
    for i = 1:p[1]
        du[i] = p[2]
    end
    du
end
""")

prob_f = Main.eval("""
function prob_func(prob, i, repeat)
    remake(prob, u0 = rand() .* prob.u0)
    end
""")

#-------------------------------------------------------------------#

K = 2.0 # coupling
N = 3 # number of nodes
dt = 0.01 # time step
t_final = 50.0 # simulation time
t_trans = 10.0 # transition time
mu = 2.0 # mean value of initial frequencies
sigma = 0.0 # std of initial frequencies
kind = 2
noise_amp = 0.001

if __name__ == " __main__":

    start = time()
    np.random.seed(1)
    theta_0 = np.random.uniform(-pi, pi, size=N)
    tspan = (0.0, t_final)

    p = [N, noise_amp]
    prob = de.SDEProblem(julia_f, julia_g, theta_0, tspan, p)
    # sol = de.solve(prob, de.SOSRA())
    ensemble_prob = de.EnsembleProblem(prob, prob_func=prob_f)
    sol = de.solve(ensemble_prob,
                   de.SOSRA(),
                   de.EnsembleThreads(),
                   trajectories=2)

```

```nohighlight
RuntimeError Traceback (most recent call last)
~/git/workshop_julia/DiffEquations/diffeqpy/synchrony_test/test_ensemble.py in <module>
     77 de.SOSRA(),
     78 de.EnsembleThreads(),
---> 79 trajectories=2)

RuntimeError: Julia exception: TaskFailedException:
UndefVarError: remake not defined

```

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [May 30, 2020, 5:10am UTC](https://discourse.julialang.org/t/debugging-diffeqpy-code-remake-not-defined/40421/2 "2020-05-30T05:10:09Z")

</div>

On the Julia side, DiffEq is only imported.

> [@Abolfazl\_Ziaeemehr](#):
>
> `UndefVarError: remake not defined`

Tells you it’s not in scope, so you need to do:

> [@Abolfazl\_Ziaeemehr](#):
>
> ```julia
> prob_f = Main.eval("""
> function prob_func(prob, i, repeat)
> DifferentialEquations.remake(prob, u0 = rand() .* prob.u0)
> end
> """)
> 
> ```
