alleninstitute / dipde Goto Github PK
View Code? Open in Web Editor NEWNumerical solver for coupled population density equations
Home Page: http://alleninstitute.github.io/dipde
License: GNU General Public License v3.0
Numerical solver for coupled population density equations
Home Page: http://alleninstitute.github.io/dipde
License: GNU General Public License v3.0
When an ExternalPopulation is accidentally set as the target of a connection, the model construction fails with an obscure error message that is unhelpful for debugging. A check should be made when the connection is attempted, and a more helpful debugging exception should be thrown.
============================= test session starts ==============================
platform linux2 -- Python 2.7.12, pytest-2.8.5, py-1.4.31, pluggy-0.3.1
rootdir: /var/tmp/dipde, inifile:
plugins: xdist-1.13.1
collected 18 items
dipde/test/test_basic.py .
dipde/test/test_delay.py F.
dipde/test/test_examples.py .....
dipde/test/test_propogation_methods.py ...
dipde/test/test_singlepop.py .
dipde/test/test_utilities.py ......
=================================== FAILURES ===================================
_____________________________ test_delay_singlepop _____________________________
def test_delay_singlepop():
# Settings:
t0 = 0.
dt = .001
tf = .005
verbose = False
# Create simulation:
b1 = ExternalPopulation('Heaviside(t)*100')
i1 = InternalPopulation(v_min=0, v_max=.02, dv=.001, update_method='exact')
b1_i1 = Connection(b1, i1, 1, weights=[.005], probs=[1.], delay=2*dt)
simulation = Simulation([b1, i1], [b1_i1], verbose=verbose)
> simulation.run(dt=dt, tf=tf, t0=t0)
dipde/test/test_delay.py:21:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
dipde/internals/simulation.py:104: in run
self.initialize(t0=t0)
dipde/internals/simulation.py:75: in initialize
p.initialize()
dipde/internals/internalpopulation.py:122: in initialize
self.initialize_total_input_dict()
dipde/internals/internalpopulation.py:193: in initialize_total_input_dict
self.total_input_dict[c.connection_distribution] = curr_input + c.curr_delayed_firing_rate * c.nsyn
dipde/internals/connection.py:148: in curr_delayed_firing_rate
self.initialize_delay_queue()
dipde/internals/connection.py:125: in initialize_delay_queue
self.delay_queue[i] = self.source.firing_rate(self.simulation.t - self.simulation.dt*i)
dipde/internals/externalpopulation.py:63: in firing_rate
if curr_firing_rate < 0:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = 100*Heaviside(0.0) < 0
def __nonzero__(self):
> raise TypeError("cannot determine truth value of Relational")
E TypeError: cannot determine truth value of Relational
/usr/lib/python2.7/site-packages/sympy/core/relational.py:195: TypeError
---------------- generated xml file: /var/tmp/dipde/result.xml -----------------
===================== 1 failed, 17 passed in 14.14 seconds =====================
Hello,
These queries came up when we were working on including dipde in NeuroFedora.
setup.py
says 'License :: Apache Software License :: 2.0',
set.py
says python 2.7 only.Thanks very much!
This function should use the argument passed in as distribution, but instead uses sps.expon. Something like:
rv = distribution(*shape, loc=loc, scale=scale)
should fix everything.
This should be simple enough to change. Also be nice to make this distributions not constants
In the latest version of sympy, Heaviside(0.0) is not defined. The old definition would be Heaviside(0.0) = 1/2. Thus, the potjans example script fails with a TypeError:
In [1]: run potjans_diesmann_cortical_column.py
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/Users/ehagen/Repositories/dipde/dipde/examples/potjans_diesmann_cortical_column.py in <module>()
113
114 # Run simulation:
--> 115 simulation.run(dt=dt, tf=tf, t0=t0)
116
117 # Visualize:
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/dipde-0.1.0-py2.7.egg/dipde/internals/simulation.pyc in run(self, t0, dt, tf)
102 # Initialize:
103 start_time = time.time()
--> 104 self.initialize(t0=t0)
105 self.initialization_time = time.time() - start_time
106
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/dipde-0.1.0-py2.7.egg/dipde/internals/simulation.pyc in initialize(self, t0)
73 # Initialize populations:
74 for p in self.population_list:
---> 75 p.initialize()
76
77 # Initialize connections:
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/dipde-0.1.0-py2.7.egg/dipde/internals/internalpopulation.pyc in initialize(self)
120 self.initialize_edges()
121 self.initialize_probability() # TODO: different initialization options
--> 122 self.initialize_total_input_dict()
123 if self.record == True: self.initialize_firing_rate_recorder()
124
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/dipde-0.1.0-py2.7.egg/dipde/internals/internalpopulation.pyc in initialize_total_input_dict(self)
191 c.initialize_connection_distribution()
192 curr_input = self.total_input_dict.setdefault(c.connection_distribution, 0)
--> 193 self.total_input_dict[c.connection_distribution] = curr_input + c.curr_delayed_firing_rate * c.nsyn
194
195 def get_total_flux_matrix(self):
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/dipde-0.1.0-py2.7.egg/dipde/internals/connection.pyc in curr_delayed_firing_rate(self)
146 return self.delay_queue[0]
147 except:
--> 148 self.initialize_delay_queue()
149 return self.delay_queue[0]
150
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/dipde-0.1.0-py2.7.egg/dipde/internals/connection.pyc in initialize_delay_queue(self)
123 self.delay_queue = np.core.numeric.zeros(self.delay_ind+1)
124 for i in range(len(self.delay_queue)):
--> 125 self.delay_queue[i] = self.source.firing_rate(self.simulation.t - self.simulation.dt*i)
126 self.delay_queue = self.delay_queue[::-1]
127 else:
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/dipde-0.1.0-py2.7.egg/dipde/internals/externalpopulation.pyc in firing_rate(self, t)
63 curr_firing_rate = self.closure(t)
64
---> 65 if curr_firing_rate < 0:
66 raise RuntimeError("negative firing rate requested: %s, at t=%s" % (self.firing_rate_string, t)) # pragma: no cover
67 # try:
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sympy/core/relational.pyc in __nonzero__(self)
193
194 def __nonzero__(self):
--> 195 raise TypeError("cannot determine truth value of Relational")
196
197 __bool__ = __nonzero__
TypeError: cannot determine truth value of Relational
An ugly fix capturing the TypeError would be:
def firing_rate(self, t):
'''Firing rate of the population at time t (Hz).'''
curr_firing_rate = self.closure(t)
# if curr_firing_rate < 0:
# raise RuntimeError("negative firing rate requested: %s, at t=%s" % (self.firing_rate_string, t)) # pragma: no cover
try:
if curr_firing_rate < 0:
raise RuntimeError("negative firing rate requested: %s, at t=%s" % (self.firing_rate_string, t)) # pragma: no cover
except TypeError as te:
curr_firing_rate /= Heaviside(0.0) * 2
if curr_firing_rate < 0:
raise RuntimeError("negative firing rate requested: %s, at t=%s" % (self.firing_rate_string, t)) # pragma: no cover
return curr_firing_rate
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.