Skip to content
Snippets Groups Projects
Select Git revision
  • 1bd65e132ebc96ff08c04cd60c822479d33b1c25
  • master default protected
  • tut_ring_allen
  • docs_furo
  • docs_reorder_cable_cell
  • docs_graphviz
  • docs_rtd_dev
  • ebrains_mirror
  • doc_recat
  • docs_spike_source
  • docs_sim_sample_clar
  • docs_pip_warn
  • github_template_updates
  • docs_fix_link
  • cv_default_and_doc_clarification
  • docs_add_numpy_req
  • readme_zenodo_05
  • install_python_fix
  • install_require_numpy
  • typofix_propetries
  • docs_recipe_lookup
  • v0.10.0
  • v0.10.1
  • v0.10.0-rc5
  • v0.10.0-rc4
  • v0.10.0-rc3
  • v0.10.0-rc2
  • v0.10.0-rc
  • v0.9.0
  • v0.9.0-rc
  • v0.8.1
  • v0.8
  • v0.8-rc
  • v0.7
  • v0.6
  • v0.5.2
  • v0.5.1
  • v0.5
  • v0.4
  • v0.3
  • v0.2.2
41 results

test_rss_cell.cpp

Blame
  • user avatar
    Wouter Klijn authored and Ben Cumming committed
    Fix bug in `rss_cell_group`s with more than one cell with different `dt` or `start_time` values.
    Fixes #410.
    1bd65e13
    History
    test_rss_cell.cpp 2.34 KiB
    #include "../gtest.h"
    
    #include <rss_cell.hpp>
    #include <rss_cell_group.hpp>
    
    #include "../simple_recipes.hpp"
    
    using namespace arb;
    
    using rss_recipe = homogeneous_recipe<cell_kind::regular_spike_source, rss_cell>;
    
    TEST(rss_cell, basic_usage)
    {
        constexpr time_type dt = 0.01; // dt is ignored by rss_cell_group::advance().
    
        // Use floating point times with an exact representation in order to avoid
        // rounding issues.
        rss_cell desc{0.125, 0.03125, 0.5};
        rss_cell_group sut({0}, rss_recipe(1u, desc));
    
        // No spikes in this time frame.
        epoch ep(0, 0.1);
        sut.advance(ep, dt, {});
        EXPECT_EQ(0u, sut.spikes().size());
    
        // Only on in this time frame
        sut.clear_spikes();
        ep.advance(0.127);
        sut.advance(ep, dt, {});
        EXPECT_EQ(1u, sut.spikes().size());
    
        // Reset cell group state.
        sut.reset();
    
        // Expect 12 spikes excluding the 0.5 end point.
        ep.advance(0.5);
        sut.advance(ep, dt, {});
        EXPECT_EQ(12u, sut.spikes().size());
    }
    
    TEST(rss_cell, poll_time_after_end_time)
    {
        constexpr time_type dt = 0.01; // dt is ignored by rss_cell_group::advance().
    
        rss_cell desc{0.125, 0.03125, 0.5};
        rss_cell_group sut({0}, rss_recipe(1u, desc));
    
        // Expect 12 spikes in this time frame.
        sut.advance(epoch(0, 0.7), dt, {});
        EXPECT_EQ(12u, sut.spikes().size());
    
        // Now ask for spikes for a time slot already passed:
        // It should result in zero spikes because of the internal state!
        sut.clear_spikes();
        sut.advance(epoch(0, 0.2), dt, {});
        EXPECT_EQ(0u, sut.spikes().size());
    
        sut.reset();
    
        // Expect 12 excluding the 0.5
        sut.advance(epoch(0, 0.5), dt, {});
        EXPECT_EQ(12u, sut.spikes().size());
    }
    
    TEST(rss_cell, rate_bigger_then_epoch)
    {
        constexpr time_type dt = 0.01; // dt is ignored by rss_cell_group::advance().
    
        rss_cell desc{ 0.0, 100.0, 1000.0 };
        rss_cell_group sut({ 0 }, rss_recipe(1u, desc));
    
        // take time steps of 10 ms
        for (time_type start = 0.0; start < 1000.0; start += 10) {
            sut.advance(epoch(start, start + 10.0), dt, {});
        }
        // We spike once every 100 ms so in 1000.0 ms we should have 10
        EXPECT_EQ(10u, sut.spikes().size());
    }
    
    
    TEST(rss_cell, cell_kind_correct)
    {
        rss_cell desc{0.1, 0.01, 0.2};
        rss_cell_group sut({0}, rss_recipe(1u, desc));
    
        EXPECT_EQ(cell_kind::regular_spike_source, sut.get_cell_kind());
    }