Giter Club home page Giter Club logo

dipde's People

Contributors

dependabot[bot] avatar kaeldai avatar nicain avatar sd1212 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dipde's Issues

Obscure Error message when connecting to ExternalPopulation

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_delay_singlepop fails with "TypeError: cannot determine truth value of Relational"

============================= 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 =====================

License and py3 clarification

Hello,

These queries came up when we were working on including dipde in NeuroFedora.

  • Is dipde made available under a GPLv3+ license? The setup.py file has a GPLv3+ header, as do other source files do, but setup.py says 'License :: Apache Software License :: 2.0',
  • Also, does dipde support python3? It seems to install fine in a python3 virtual environment, but set.py says python 2.7 only.

Thanks very much!

Relation TypeError w. Sympy v.1.0's Heaviside implementation

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.