generated from djanloo/cythonTemplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
my_profile.py
46 lines (30 loc) · 915 Bytes
/
my_profile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
"""Profiling examle using line_profiler.
"""
from os import chdir
from os.path import dirname, join
from line_profiler import LineProfiler
from numneur import neur, networks
import numpy as np
import matplotlib.pyplot as plt
from rich import print
# Sets the working directory as the one with the code inside
# Without this line line_profiler won't find anything
chdir(join(dirname(__file__), "numneur"))
lp = LineProfiler()
lp.add_function(neur.neuronet)
lp.add_function(networks.watts_strogatz)
lp.add_function(networks.parents_and_children)
wrap = lp(neur.neuronet)
dt = 1e-2
I = 10*np.ones(10_000)
M = 10
# g0 = np.random.uniform(0,0.5, size=(M,M))
adj = networks.watts_strogatz(M, 6, .1)
for i in range(M):
adj[i,i] = 0
g0 = adj*np.random.uniform(0,.5, size=(M,M))
bursting = dict(c=-55.0, d=4)
v, f = wrap(I, g0, Esyn=0.0, dt=dt ,**bursting)
for vv in v:
plt.plot(vv)
lp.print_stats()