From 922add0dbcfcba9b7517349fb855b4323e64d2da Mon Sep 17 00:00:00 2001
From: Sam Yates <halfflat@gmail.com>
Date: Wed, 28 Oct 2020 20:34:13 +0100
Subject: [PATCH] Correct sense of target vs synapse count test. (#1203)

* Swap arguments in target count check in `fvm_lowered_cell_impl.hpp`.
* Update unit test to suit.
---
 arbor/fvm_lowered_cell_impl.hpp | 2 +-
 test/unit/test_recipe.cpp       | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arbor/fvm_lowered_cell_impl.hpp b/arbor/fvm_lowered_cell_impl.hpp
index 3851ef02..701576cf 100644
--- a/arbor/fvm_lowered_cell_impl.hpp
+++ b/arbor/fvm_lowered_cell_impl.hpp
@@ -540,7 +540,7 @@ void fvm_lowered_cell_impl<Backend>::initialize(
             throw arb::bad_source_description(gid, rec.num_sources(gid), cell.detectors().size());;
         }
         auto cell_targets = util::sum_by(cell.synapses(), [](auto& syn) {return syn.second.size();});
-        if (cell_targets > rec.num_targets(gid)) {
+        if (rec.num_targets(gid) > cell_targets) {
             throw arb::bad_target_description(gid, rec.num_targets(gid), cell_targets);
         }
 
diff --git a/test/unit/test_recipe.cpp b/test/unit/test_recipe.cpp
index 888b4da8..c325af64 100644
--- a/test/unit/test_recipe.cpp
+++ b/test/unit/test_recipe.cpp
@@ -141,7 +141,7 @@ TEST(recipe, num_targets)
         EXPECT_NO_THROW(simulation(recipe_0, decomp_0, context));
     }
     {
-        auto recipe_1 = custom_recipe({cell}, {0}, {1}, {{}}, {{}});
+        auto recipe_1 = custom_recipe({cell}, {0}, {3}, {{}}, {{}});
         auto decomp_1 = partition_load_balance(recipe_1, context);
 
         EXPECT_THROW(simulation(recipe_1, decomp_1, context), arb::bad_target_description);
-- 
GitLab