From bb92d148deccccba6688b362e04633dac6896cda Mon Sep 17 00:00:00 2001 From: Alessandro Cattabiani Date: Wed, 20 Aug 2025 13:13:21 +0200 Subject: [PATCH 1/8] test CI --- include/bbp/sonata/config.h | 13 ++++++++++--- src/config.cpp | 20 ++++++++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/include/bbp/sonata/config.h b/include/bbp/sonata/config.h index aa2be41..da776dd 100644 --- a/include/bbp/sonata/config.h +++ b/include/bbp/sonata/config.h @@ -457,8 +457,10 @@ class SONATA_API SimulationConfig double delay{}; /// Time duration for how long input is activated (ms) double duration{}; - /// Node set which is affected by input - std::string nodeSet; + /// Node set which is affected by input. Not allowed in case of CompartmentSet + nonstd::optional nodeSet{nonstd::nullopt}; + /// CompartmentSet which is affected by the input. It has priority over nodeSet + nonstd::optional compartmentSet{nonstd::nullopt}; }; struct InputLinear: public InputBase { @@ -796,10 +798,15 @@ class SONATA_API SimulationConfig const std::string& getCompartmentSetsFile() const noexcept; /** - * Returns the name of node set to be instantiated for the simulation, default = None + * Returns the name of the node set to be instantiated for the simulation, default = None */ const nonstd::optional& getNodeSet() const noexcept; + /** + * Returns the name of the compartment set to be instantiated for the simulation, default = None + */ + const nonstd::optional& getComaprtmentSet() const noexcept; + /** * Returns the metadata section */ diff --git a/src/config.cpp b/src/config.cpp index a604460..2d11992 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -404,6 +404,26 @@ SimulationConfig::Input parseInputModule(const nlohmann::json& valueIt, parseMandatory(valueIt, "delay", debugStr, input.delay); parseMandatory(valueIt, "duration", debugStr, input.duration); parseMandatory(valueIt, "node_set", debugStr, input.nodeSet); + parseOptional(valueIt, "node_set", input.nodeSet); + parseOptional(valueIt, "compartment_set", input.compartmentSet); + + const auto nodeSet = valueIt.find("node_set"); + const auto compartmentSet = valueIt.find("compartment_set"); + + if (nodeSet != valueIt.end()) { + parseOptional(valueIt, "node_set", input.nodeSet); + } + + if (compartmentSet != valueIt.end()) { + parseOptional(valueIt, "compartment_set", input.compartmentSet); + } + + if (input.nodeSet.has_value() && input.compartmentSet.has_value()) { + throw SonataError("`node_set` is not allowed if `compartment_set` is set in " + debugStr); + } else if (!input.nodeSet.has_value() && !input.compartmentSet.has_value()) { + throw SonataError("One of `node_set` or `compartment_set` need to have a value in " + + debugStr); + } }; switch (module) { From 6e165cd5a0cc846ac8d856e5b8dc662457a45ccb Mon Sep 17 00:00:00 2001 From: Alessandro Cattabiani Date: Wed, 20 Aug 2025 13:27:43 +0200 Subject: [PATCH 2/8] format --- .vscode/settings.json | 59 ++++++++++++++++++++++++++++++++++++++++++ concretization.txt | 60 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 119 insertions(+) create mode 100644 .vscode/settings.json create mode 100644 concretization.txt diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..5c229dc --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,59 @@ +{ + "files.associations": { + "*.h5": "", + "vector": "cpp", + "__split_buffer": "cpp", + "deque": "cpp", + "string": "cpp", + "__bit_reference": "cpp", + "__hash_table": "cpp", + "__locale": "cpp", + "__node_handle": "cpp", + "__tree": "cpp", + "__verbose_abort": "cpp", + "array": "cpp", + "bitset": "cpp", + "cctype": "cpp", + "cinttypes": "cpp", + "clocale": "cpp", + "cmath": "cpp", + "complex": "cpp", + "cstdarg": "cpp", + "cstdint": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cstring": "cpp", + "ctime": "cpp", + "cwchar": "cpp", + "cwctype": "cpp", + "execution": "cpp", + "forward_list": "cpp", + "initializer_list": "cpp", + "ios": "cpp", + "iosfwd": "cpp", + "iostream": "cpp", + "istream": "cpp", + "limits": "cpp", + "locale": "cpp", + "map": "cpp", + "mutex": "cpp", + "new": "cpp", + "optional": "cpp", + "print": "cpp", + "queue": "cpp", + "ratio": "cpp", + "regex": "cpp", + "set": "cpp", + "sstream": "cpp", + "stack": "cpp", + "stdexcept": "cpp", + "streambuf": "cpp", + "string_view": "cpp", + "typeinfo": "cpp", + "unordered_map": "cpp", + "valarray": "cpp", + "variant": "cpp", + "fstream": "cpp", + "algorithm": "cpp" + } +} \ No newline at end of file diff --git a/concretization.txt b/concretization.txt new file mode 100644 index 0000000..f044aa8 --- /dev/null +++ b/concretization.txt @@ -0,0 +1,60 @@ +==> Concretized py-libsonata + - ac7ixav py-libsonata@0.1.30%clang@16.0.6 build_system=python_pip arch=darwin-macos-m1 +[+] wljx6jn ^cmake@3.27.7%clang@16.0.6~doc+ncurses+ownlibs build_system=generic build_type=Release arch=darwin-macos-m1 +[e] fg7kncs ^curl@8.7.1%clang@16.0.6+gssapi+ldap~libidn2~librtmp~libssh~libssh2+nghttp2 build_system=autotools libs=shared,static tls=secure_transport arch=darwin-macos-m1 +[+] oh54oqg ^ncurses@6.4%clang@16.0.6~symlinks+termlib abi=none build_system=autotools arch=darwin-macos-m1 +[+] ojdbz5r ^gnuconfig@2022-09-17%clang@16.0.6 build_system=generic arch=darwin-macos-m1 +[+] ixgctpi ^zlib-ng@2.1.4%clang@16.0.6+compat+opt build_system=autotools arch=darwin-macos-m1 +[+] ulf4r3h ^fmt@10.1.1%clang@16.0.6~ipo+pic~shared build_system=cmake build_type=Release cxxstd=11 generator=make arch=darwin-macos-m1 +[e] 4vpmzvy ^gmake@3.81%clang@16.0.6~guile build_system=generic patches=ca60bd9 arch=darwin-macos-m1 +[+] t6hu67o ^hdf5@1.14.3%clang@16.0.6~cxx~fortran+hl~ipo~java~map+mpi+shared~szip~threadsafe+tools api=default build_system=cmake build_type=Release generator=make arch=darwin-macos-m1 +[+] suztp7c ^openmpi@4.1.6%clang@16.0.6~atomics~cuda~cxx~cxx_exceptions~gpfs~internal-hwloc~internal-pmix~java~legacylaunchers~lustre~memchecker~openshmem~orterunprefix+romio+rsh~singularity+static+vt+wrapper-rpath build_system=autotools fabrics=none schedulers=none arch=darwin-macos-m1 +[+] 4ainykl ^hwloc@2.9.1%clang@16.0.6~cairo~cuda~gl~libudev+libxml2~netloc~nvml~oneapi-level-zero~opencl~pci~rocm build_system=autotools libs=shared,static arch=darwin-macos-m1 +[e] avyxw6s ^openssh@9.9p2%clang@16.0.6+gssapi build_system=autotools patches=3505c58,d886b98 arch=darwin-macos-m1 +[+] sb5y3kz ^perl@5.38.0%clang@16.0.6+cpanm+opcode+open+shared+threads build_system=generic patches=714e4d1 arch=darwin-macos-m1 +[+] igqkdlg ^berkeley-db@18.1.40%clang@16.0.6+cxx~docs+stl build_system=autotools patches=26090f4,b231fcc arch=darwin-macos-m1 +[+] 4l6e37g ^pmix@5.0.1%clang@16.0.6~docs+pmi_backwards_compatibility~python~restful build_system=autotools arch=darwin-macos-m1 +[+] u7zxtnx ^libevent@2.1.12%clang@16.0.6+openssl build_system=autotools arch=darwin-macos-m1 +[+] unb3wau ^autoconf@2.69%clang@16.0.6 build_system=autotools patches=35c4492,7793209,a49dd5b arch=darwin-macos-m1 +[e] c6lm4fx ^m4@1.4.6%clang@16.0.6+sigsegv build_system=autotools arch=darwin-macos-m1 +[+] u26zydc ^automake@1.16.5%clang@16.0.6 build_system=autotools arch=darwin-macos-m1 +[+] rxn4r2p ^libtool@2.4.7%clang@16.0.6 build_system=autotools arch=darwin-macos-m1 +[+] mroqcvh ^pkgconf@1.9.5%clang@16.0.6 build_system=autotools arch=darwin-macos-m1 +[+] tnkqnos ^highfive@2.10.0%clang@16.0.6~boost~eigen~ipo+mpi~xtensor build_system=cmake build_type=Release generator=make arch=darwin-macos-m1 +[+] t5yi2r6 ^nlohmann-json@3.9.1%clang@16.0.6~ipo+multiple_headers build_system=cmake build_type=Release generator=make arch=darwin-macos-m1 +[+] tdtbfex ^py-numpy@1.26.1%clang@16.0.6 build_system=python_pip patches=873745d arch=darwin-macos-m1 +[+] vbhq3uk ^ninja@1.11.1%clang@16.0.6+re2c build_system=generic arch=darwin-macos-m1 +[+] v5lkqi7 ^re2c@2.2%clang@16.0.6 build_system=generic arch=darwin-macos-m1 +[e] 67voqz2 ^openblas@0.3.24%clang@16.0.6~bignuma~consistent_fpcsr+fortran~ilp64+locking+pic+shared build_system=makefile symbol_suffix=none threads=none arch=darwin-macos-m1 +[+] xt3yny4 ^py-cython@0.29.36%clang@16.0.6 build_system=python_pip patches=c4369ad arch=darwin-macos-m1 +[+] jzgli7j ^py-pyproject-metadata@0.7.1%clang@16.0.6 build_system=python_pip arch=darwin-macos-m1 +[+] q7z5xrr ^py-pip@23.1.2%clang@16.0.6 build_system=generic arch=darwin-macos-m1 +[+] cjkvf75 ^py-pybind11@2.11.0%clang@16.0.6~ipo build_system=cmake build_type=Release generator=ninja arch=darwin-macos-m1 +[+] gy7mphw ^py-setuptools@68.0.0%clang@16.0.6 build_system=generic arch=darwin-macos-m1 +[+] wditibp ^py-setuptools-scm@8.0.4%clang@16.0.6+toml build_system=python_pip arch=darwin-macos-m1 +[e] o2wwfha ^git@2.39.5%clang@16.0.6+man+nls+perl+subtree~svn~tcltk build_system=autotools arch=darwin-macos-m1 +[+] athvzx3 ^py-packaging@23.1%clang@16.0.6 build_system=python_pip arch=darwin-macos-m1 +[+] aahjzwa ^py-flit-core@3.9.0%clang@16.0.6 build_system=python_pip arch=darwin-macos-m1 +[+] 63tk43p ^py-tomli@2.0.1%clang@16.0.6 build_system=python_pip arch=darwin-macos-m1 +[+] gcnx7k3 ^py-typing-extensions@4.8.0%clang@16.0.6 build_system=python_pip arch=darwin-macos-m1 +[+] prtzj2u ^py-wheel@0.41.2%clang@16.0.6 build_system=generic arch=darwin-macos-m1 +[+] j6zaiiu ^python@3.11.6%clang@16.0.6+bz2+crypt+ctypes+dbm~debug+libxml2+lzma~nis~optimizations+pic+pyexpat+pythoncmd+readline+shared+sqlite3+ssl~tkinter+uuid+zlib build_system=generic patches=13fa8bf,b0615b2,ebdca64,f2fd060 arch=darwin-macos-m1 +[e] ueihcfy ^apple-libuuid@1353.100.2%clang@16.0.6 build_system=bundle arch=darwin-macos-m1 +[+] 7ijbvg3 ^bzip2@1.0.8%clang@16.0.6~debug~pic+shared build_system=generic arch=darwin-macos-m1 +[+] bku3pxt ^diffutils@3.9%clang@16.0.6 build_system=autotools arch=darwin-macos-m1 +[+] qsg7k24 ^expat@2.5.0%clang@16.0.6~libbsd build_system=autotools arch=darwin-macos-m1 +[+] k3w6kae ^gdbm@1.23%clang@16.0.6 build_system=autotools arch=darwin-macos-m1 +[+] jnfyb2c ^gettext@0.22.3%clang@16.0.6+bzip2+curses+git~libunistring+libxml2+pic+shared+tar+xz build_system=autotools arch=darwin-macos-m1 +[+] hc4edf4 ^libiconv@1.17%clang@16.0.6 build_system=autotools libs=shared,static arch=darwin-macos-m1 +[+] u6jodzh ^libxml2@2.10.3%clang@16.0.6+pic~python+shared build_system=autotools arch=darwin-macos-m1 +[+] nyowhin ^tar@1.34%clang@16.0.6 build_system=autotools zip=pigz arch=darwin-macos-m1 +[+] 7t5dqak ^pigz@2.7%clang@16.0.6 build_system=makefile arch=darwin-macos-m1 +[+] rzlxhkd ^zstd@1.5.5%clang@16.0.6+programs build_system=makefile compression=none libs=shared,static arch=darwin-macos-m1 +[e] fhbmz3a ^libffi@3.4.4%clang@16.0.6 build_system=autotools arch=darwin-macos-m1 +[+] mt2inqh ^libxcrypt@4.4.35%clang@16.0.6~obsolete_api build_system=autotools patches=4885da3 arch=darwin-macos-m1 +[e] 3b4iznu ^openssl@3.4.0%clang@16.0.6~docs+shared build_system=generic certs=mozilla arch=darwin-macos-m1 +[+] uyiawy7 ^readline@8.2%clang@16.0.6 build_system=autotools patches=bbf97f1 arch=darwin-macos-m1 +[+] rhasc72 ^sqlite@3.43.2%clang@16.0.6+column_metadata+dynamic_extensions+fts~functions+rtree build_system=autotools arch=darwin-macos-m1 +[+] lg2cln5 ^xz@5.4.1%clang@16.0.6~pic build_system=autotools libs=shared,static arch=darwin-macos-m1 + +==> Updating view at /Users/katta/OBI/libsonata/spackenv/.spack-env/view From 8e075c91ca7f0a6403582bfb6b340e437ed61aa3 Mon Sep 17 00:00:00 2001 From: Alessandro Cattabiani Date: Wed, 20 Aug 2025 13:27:58 +0200 Subject: [PATCH 3/8] changes format --- src/config.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/config.cpp b/src/config.cpp index 2d11992..b25ccbf 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -419,7 +419,8 @@ SimulationConfig::Input parseInputModule(const nlohmann::json& valueIt, } if (input.nodeSet.has_value() && input.compartmentSet.has_value()) { - throw SonataError("`node_set` is not allowed if `compartment_set` is set in " + debugStr); + throw SonataError("`node_set` is not allowed if `compartment_set` is set in " + + debugStr); } else if (!input.nodeSet.has_value() && !input.compartmentSet.has_value()) { throw SonataError("One of `node_set` or `compartment_set` need to have a value in " + debugStr); From 589d4b32e8803e5da8449961190a79359e88f5a2 Mon Sep 17 00:00:00 2001 From: Alessandro Cattabiani Date: Wed, 20 Aug 2025 17:02:28 +0200 Subject: [PATCH 4/8] final version + tests --- python/bindings.cpp | 5 ++- python/generated/docstrings.h | 2 + python/tests/test_config.py | 45 +++++++++++++++++++ src/config.cpp | 2 +- tests/data/config/simulation_config.json | 8 ++++ tests/test_config.cpp | 57 ++++++++++++++++++++++-- 6 files changed, 114 insertions(+), 5 deletions(-) diff --git a/python/bindings.cpp b/python/bindings.cpp index 04fdeeb..a2efd58 100644 --- a/python/bindings.cpp +++ b/python/bindings.cpp @@ -967,7 +967,10 @@ PYBIND11_MODULE(_libsonata, m) { DOC_SIMULATIONCONFIG(InputBase, duration)) .def_readonly("node_set", &SimulationConfig::InputBase::nodeSet, - DOC_SIMULATIONCONFIG(InputBase, nodeSet)); + DOC_SIMULATIONCONFIG(InputBase, nodeSet)) + .def_readonly("compartment_set", + &SimulationConfig::InputBase::compartmentSet, + DOC_SIMULATIONCONFIG(InputBase, compartmentSet)); py::class_(simConf, "Linear") .def_readonly("amp_start", diff --git a/python/generated/docstrings.h b/python/generated/docstrings.h index 82d6029..ca20621 100644 --- a/python/generated/docstrings.h +++ b/python/generated/docstrings.h @@ -893,6 +893,8 @@ static const char *__doc_bbp_sonata_SimulationConfig_InputBase_module = R"doc(Ty static const char *__doc_bbp_sonata_SimulationConfig_InputBase_nodeSet = R"doc(Node set which is affected by input)doc"; +static const char *__doc_bbp_sonata_SimulationConfig_InputBase_compartmentSet = R"doc(Compartment set which is affected by input)doc"; + static const char *__doc_bbp_sonata_SimulationConfig_InputHyperpolarizing = R"doc()doc"; static const char *__doc_bbp_sonata_SimulationConfig_InputHyperpolarizing_representsPhysicalElectrode = R"doc(Whether this input represents a physical electrode. Default is false)doc"; diff --git a/python/tests/test_config.py b/python/tests/test_config.py index 119b031..a77e505 100644 --- a/python/tests/test_config.py +++ b/python/tests/test_config.py @@ -486,6 +486,7 @@ def test_basic(self): "ex_extracellular_stimulation", "ex_hyperpolarizing", "ex_linear", + "ex_linear_compartment_set", "ex_noise_mean", "ex_noise_meanpercent", "ex_OU", @@ -506,9 +507,13 @@ def test_basic(self): self.assertEqual(self.config.input('ex_linear').delay, 0) self.assertEqual(self.config.input('ex_linear').duration, 15) self.assertEqual(self.config.input('ex_linear').node_set, "Column") + self.assertEqual(self.config.input('ex_linear').compartment_set, None) self.assertEqual(self.config.input('ex_linear').amp_start, 0.15) self.assertEqual(self.config.input('ex_linear').amp_end, 0.15) + self.assertEqual(self.config.input('ex_linear_compartment_set').node_set, None) + self.assertEqual(self.config.input('ex_linear_compartment_set').compartment_set, "cs1") + self.assertEqual(self.config.input('ex_rel_linear').input_type.name, 'current_clamp') self.assertEqual(self.config.input('ex_rel_linear').module.name, 'relative_linear') self.assertEqual(self.config.input('ex_rel_linear').delay, 0) @@ -723,3 +728,43 @@ def test_simulation_config_failures(self): """ SimulationConfig(contents, "./") self.assertEqual(e.exception.args, ('Replay spike_file should be a SONATA h5 file', )) + + with self.assertRaises(SonataError) as e: + contents = """ + { + "run": { "random_seed": 12345, "dt": 0.05, "tstop": 1000 }, + "inputs" : { + "ex_linear": { + "input_type": "current_clamp", + "module": "linear", + "amp_start": 0.15, + "delay": 0, + "duration": 15, + "node_set":"Column", + "compartment_set":"cs1" + } + } + } + """ + SimulationConfig(contents, "./") + self.assertEqual(e.exception.args, ('`node_set` is not allowed if `compartment_set` is set in input ex_linear', )) + + with self.assertRaises(SonataError) as e: + contents = """ + { + "run": { "random_seed": 12345, "dt": 0.05, "tstop": 1000 }, + "inputs" : { + "ex_linear": { + "input_type": "current_clamp", + "module": "linear", + "amp_start": 0.15, + "delay": 0, + "duration": 15 + } + } + } + """ + SimulationConfig(contents, "./") + self.assertEqual(e.exception.args, ('One of `node_set` or `compartment_set` need to have a value in input ex_linear', )) + + diff --git a/src/config.cpp b/src/config.cpp index b25ccbf..87c561b 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -403,7 +403,7 @@ SimulationConfig::Input parseInputModule(const nlohmann::json& valueIt, parseMandatory(valueIt, "input_type", debugStr, input.inputType); parseMandatory(valueIt, "delay", debugStr, input.delay); parseMandatory(valueIt, "duration", debugStr, input.duration); - parseMandatory(valueIt, "node_set", debugStr, input.nodeSet); + parseOptional(valueIt, "node_set", input.nodeSet); parseOptional(valueIt, "compartment_set", input.compartmentSet); diff --git a/tests/data/config/simulation_config.json b/tests/data/config/simulation_config.json index e570d54..e54fe51 100644 --- a/tests/data/config/simulation_config.json +++ b/tests/data/config/simulation_config.json @@ -73,6 +73,14 @@ "duration": 15, "node_set":"Column" }, + "ex_linear_compartment_set": { + "input_type": "current_clamp", + "module": "linear", + "amp_start": 0.15, + "delay": 0, + "duration": 15, + "compartment_set":"cs1" + }, "ex_rel_linear": { "input_type": "current_clamp", "module": "relative_linear", diff --git a/tests/test_config.cpp b/tests/test_config.cpp index 205023d..a0c2746 100644 --- a/tests/test_config.cpp +++ b/tests/test_config.cpp @@ -359,7 +359,6 @@ TEST_CASE("SimulationConfig") { CHECK(configAllSects.sectionConfigure == "%s.gSK_E2bar_SK_E2 = 0"); CHECK_THROWS_AS(config.getReport("DoesNotExist"), SonataError); - CHECK(config.listReportNames() == std::set{ "axonal_comp_centers", "cell_imembrane", @@ -587,6 +586,7 @@ TEST_CASE("SimulationConfig") { "ex_extracellular_stimulation", "ex_hyperpolarizing", "ex_linear", + "ex_linear_compartment_set", "ex_noise_mean", "ex_noise_meanpercent", "ex_OU", @@ -1203,14 +1203,65 @@ TEST_CASE("SimulationConfig") { "inputs": { "linear": { "input_type": "current_clamp", - "module": "spike_replay", + "module": "linear", "delay": 0, "duration": 15, "node_set":"Column" } } })"; - CHECK_THROWS_AS(SimulationConfig(contents, "./"), SonataError); +CHECK_THROWS_WITH( + SimulationConfig(contents, "./"), + Catch::Matchers::Contains("amp_start") +); + } + { // Both node_set and compartment_set are given in an input object + auto contents = R"({ + "run": { + "random_seed": 12345, + "dt": 0.05, + "tstop": 1000 + }, + "inputs": { + "linear": { + "input_type": "current_clamp", + "module": "linear", + "delay": 0, + "duration": 15, + "amp_start": 1, + "node_set":"Column", + "compartment_set":"cs1" + } + } + })"; +CHECK_THROWS_WITH( + SimulationConfig(contents, "./"), + Catch::Matchers::Contains("node_set") && + Catch::Matchers::Contains("compartment_set") +); + } + { // Both node_set and compartment_set are missing in an input object + auto contents = R"({ + "run": { + "random_seed": 12345, + "dt": 0.05, + "tstop": 1000 + }, + "inputs": { + "linear": { + "input_type": "current_clamp", + "module": "linear", + "delay": 0, + "duration": 15, + "amp_start": 1 + } + } + })"; +CHECK_THROWS_WITH( + SimulationConfig(contents, "./"), + Catch::Matchers::Contains("node_set") && + Catch::Matchers::Contains("compartment_set") +); } { // Both mean and mean_percent are given in a noise input object auto contents = R"({ From 50fe4b632d6a05be64987a617c645e0243b17b9e Mon Sep 17 00:00:00 2001 From: Alessandro Cattabiani Date: Wed, 20 Aug 2025 17:03:18 +0200 Subject: [PATCH 5/8] format --- tests/test_config.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/test_config.cpp b/tests/test_config.cpp index a0c2746..a7f1b0a 100644 --- a/tests/test_config.cpp +++ b/tests/test_config.cpp @@ -1234,11 +1234,11 @@ CHECK_THROWS_WITH( } } })"; -CHECK_THROWS_WITH( - SimulationConfig(contents, "./"), - Catch::Matchers::Contains("node_set") && - Catch::Matchers::Contains("compartment_set") -); + CHECK_THROWS_WITH( + SimulationConfig(contents, "./"), + Catch::Matchers::Contains("node_set") && + Catch::Matchers::Contains("compartment_set") + ); } { // Both node_set and compartment_set are missing in an input object auto contents = R"({ @@ -1257,11 +1257,11 @@ CHECK_THROWS_WITH( } } })"; -CHECK_THROWS_WITH( - SimulationConfig(contents, "./"), - Catch::Matchers::Contains("node_set") && - Catch::Matchers::Contains("compartment_set") -); + CHECK_THROWS_WITH( + SimulationConfig(contents, "./"), + Catch::Matchers::Contains("node_set") && + Catch::Matchers::Contains("compartment_set") + ); } { // Both mean and mean_percent are given in a noise input object auto contents = R"({ From cebe805975f21ed668681f16e64fc09e556ff9d0 Mon Sep 17 00:00:00 2001 From: Alessandro Cattabiani Date: Wed, 20 Aug 2025 17:15:17 +0200 Subject: [PATCH 6/8] formatting test --- tests/test_config.cpp | 62 +++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/tests/test_config.cpp b/tests/test_config.cpp index a7f1b0a..ae675b4 100644 --- a/tests/test_config.cpp +++ b/tests/test_config.cpp @@ -1202,18 +1202,18 @@ TEST_CASE("SimulationConfig") { }, "inputs": { "linear": { - "input_type": "current_clamp", - "module": "linear", - "delay": 0, - "duration": 15, - "node_set":"Column" + "input_type": "current_clamp", + "module": "linear", + "delay": 0, + "duration": 15, + "node_set":"Column" } } })"; -CHECK_THROWS_WITH( - SimulationConfig(contents, "./"), - Catch::Matchers::Contains("amp_start") -); + CHECK_THROWS_WITH( + SimulationConfig(contents, "./"), + Catch::Matchers::Contains("amp_start") + ); } { // Both node_set and compartment_set are given in an input object auto contents = R"({ @@ -1224,21 +1224,21 @@ CHECK_THROWS_WITH( }, "inputs": { "linear": { - "input_type": "current_clamp", - "module": "linear", - "delay": 0, - "duration": 15, - "amp_start": 1, - "node_set":"Column", - "compartment_set":"cs1" + "input_type": "current_clamp", + "module": "linear", + "delay": 0, + "duration": 15, + "amp_start": 1, + "node_set":"Column", + "compartment_set":"cs1" } } })"; - CHECK_THROWS_WITH( - SimulationConfig(contents, "./"), - Catch::Matchers::Contains("node_set") && - Catch::Matchers::Contains("compartment_set") - ); + CHECK_THROWS_WITH( + SimulationConfig(contents, "./"), + Catch::Matchers::Contains("node_set") && + Catch::Matchers::Contains("compartment_set") + ); } { // Both node_set and compartment_set are missing in an input object auto contents = R"({ @@ -1249,19 +1249,19 @@ CHECK_THROWS_WITH( }, "inputs": { "linear": { - "input_type": "current_clamp", - "module": "linear", - "delay": 0, - "duration": 15, - "amp_start": 1 + "input_type": "current_clamp", + "module": "linear", + "delay": 0, + "duration": 15, + "amp_start": 1 } } })"; - CHECK_THROWS_WITH( - SimulationConfig(contents, "./"), - Catch::Matchers::Contains("node_set") && - Catch::Matchers::Contains("compartment_set") - ); + CHECK_THROWS_WITH( + SimulationConfig(contents, "./"), + Catch::Matchers::Contains("node_set") && + Catch::Matchers::Contains("compartment_set") + ); } { // Both mean and mean_percent are given in a noise input object auto contents = R"({ From 71aa34986fdc709ec23be4bfc8fb26cfe4bc6471 Mon Sep 17 00:00:00 2001 From: Alessandro Cattabiani Date: Wed, 20 Aug 2025 18:44:16 +0200 Subject: [PATCH 7/8] remove useless files --- .vscode/settings.json | 59 ------------------------------------------ concretization.txt | 60 ------------------------------------------- 2 files changed, 119 deletions(-) delete mode 100644 .vscode/settings.json delete mode 100644 concretization.txt diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 5c229dc..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "files.associations": { - "*.h5": "", - "vector": "cpp", - "__split_buffer": "cpp", - "deque": "cpp", - "string": "cpp", - "__bit_reference": "cpp", - "__hash_table": "cpp", - "__locale": "cpp", - "__node_handle": "cpp", - "__tree": "cpp", - "__verbose_abort": "cpp", - "array": "cpp", - "bitset": "cpp", - "cctype": "cpp", - "cinttypes": "cpp", - "clocale": "cpp", - "cmath": "cpp", - "complex": "cpp", - "cstdarg": "cpp", - "cstdint": "cpp", - "cstdio": "cpp", - "cstdlib": "cpp", - "cstring": "cpp", - "ctime": "cpp", - "cwchar": "cpp", - "cwctype": "cpp", - "execution": "cpp", - "forward_list": "cpp", - "initializer_list": "cpp", - "ios": "cpp", - "iosfwd": "cpp", - "iostream": "cpp", - "istream": "cpp", - "limits": "cpp", - "locale": "cpp", - "map": "cpp", - "mutex": "cpp", - "new": "cpp", - "optional": "cpp", - "print": "cpp", - "queue": "cpp", - "ratio": "cpp", - "regex": "cpp", - "set": "cpp", - "sstream": "cpp", - "stack": "cpp", - "stdexcept": "cpp", - "streambuf": "cpp", - "string_view": "cpp", - "typeinfo": "cpp", - "unordered_map": "cpp", - "valarray": "cpp", - "variant": "cpp", - "fstream": "cpp", - "algorithm": "cpp" - } -} \ No newline at end of file diff --git a/concretization.txt b/concretization.txt deleted file mode 100644 index f044aa8..0000000 --- a/concretization.txt +++ /dev/null @@ -1,60 +0,0 @@ -==> Concretized py-libsonata - - ac7ixav py-libsonata@0.1.30%clang@16.0.6 build_system=python_pip arch=darwin-macos-m1 -[+] wljx6jn ^cmake@3.27.7%clang@16.0.6~doc+ncurses+ownlibs build_system=generic build_type=Release arch=darwin-macos-m1 -[e] fg7kncs ^curl@8.7.1%clang@16.0.6+gssapi+ldap~libidn2~librtmp~libssh~libssh2+nghttp2 build_system=autotools libs=shared,static tls=secure_transport arch=darwin-macos-m1 -[+] oh54oqg ^ncurses@6.4%clang@16.0.6~symlinks+termlib abi=none build_system=autotools arch=darwin-macos-m1 -[+] ojdbz5r ^gnuconfig@2022-09-17%clang@16.0.6 build_system=generic arch=darwin-macos-m1 -[+] ixgctpi ^zlib-ng@2.1.4%clang@16.0.6+compat+opt build_system=autotools arch=darwin-macos-m1 -[+] ulf4r3h ^fmt@10.1.1%clang@16.0.6~ipo+pic~shared build_system=cmake build_type=Release cxxstd=11 generator=make arch=darwin-macos-m1 -[e] 4vpmzvy ^gmake@3.81%clang@16.0.6~guile build_system=generic patches=ca60bd9 arch=darwin-macos-m1 -[+] t6hu67o ^hdf5@1.14.3%clang@16.0.6~cxx~fortran+hl~ipo~java~map+mpi+shared~szip~threadsafe+tools api=default build_system=cmake build_type=Release generator=make arch=darwin-macos-m1 -[+] suztp7c ^openmpi@4.1.6%clang@16.0.6~atomics~cuda~cxx~cxx_exceptions~gpfs~internal-hwloc~internal-pmix~java~legacylaunchers~lustre~memchecker~openshmem~orterunprefix+romio+rsh~singularity+static+vt+wrapper-rpath build_system=autotools fabrics=none schedulers=none arch=darwin-macos-m1 -[+] 4ainykl ^hwloc@2.9.1%clang@16.0.6~cairo~cuda~gl~libudev+libxml2~netloc~nvml~oneapi-level-zero~opencl~pci~rocm build_system=autotools libs=shared,static arch=darwin-macos-m1 -[e] avyxw6s ^openssh@9.9p2%clang@16.0.6+gssapi build_system=autotools patches=3505c58,d886b98 arch=darwin-macos-m1 -[+] sb5y3kz ^perl@5.38.0%clang@16.0.6+cpanm+opcode+open+shared+threads build_system=generic patches=714e4d1 arch=darwin-macos-m1 -[+] igqkdlg ^berkeley-db@18.1.40%clang@16.0.6+cxx~docs+stl build_system=autotools patches=26090f4,b231fcc arch=darwin-macos-m1 -[+] 4l6e37g ^pmix@5.0.1%clang@16.0.6~docs+pmi_backwards_compatibility~python~restful build_system=autotools arch=darwin-macos-m1 -[+] u7zxtnx ^libevent@2.1.12%clang@16.0.6+openssl build_system=autotools arch=darwin-macos-m1 -[+] unb3wau ^autoconf@2.69%clang@16.0.6 build_system=autotools patches=35c4492,7793209,a49dd5b arch=darwin-macos-m1 -[e] c6lm4fx ^m4@1.4.6%clang@16.0.6+sigsegv build_system=autotools arch=darwin-macos-m1 -[+] u26zydc ^automake@1.16.5%clang@16.0.6 build_system=autotools arch=darwin-macos-m1 -[+] rxn4r2p ^libtool@2.4.7%clang@16.0.6 build_system=autotools arch=darwin-macos-m1 -[+] mroqcvh ^pkgconf@1.9.5%clang@16.0.6 build_system=autotools arch=darwin-macos-m1 -[+] tnkqnos ^highfive@2.10.0%clang@16.0.6~boost~eigen~ipo+mpi~xtensor build_system=cmake build_type=Release generator=make arch=darwin-macos-m1 -[+] t5yi2r6 ^nlohmann-json@3.9.1%clang@16.0.6~ipo+multiple_headers build_system=cmake build_type=Release generator=make arch=darwin-macos-m1 -[+] tdtbfex ^py-numpy@1.26.1%clang@16.0.6 build_system=python_pip patches=873745d arch=darwin-macos-m1 -[+] vbhq3uk ^ninja@1.11.1%clang@16.0.6+re2c build_system=generic arch=darwin-macos-m1 -[+] v5lkqi7 ^re2c@2.2%clang@16.0.6 build_system=generic arch=darwin-macos-m1 -[e] 67voqz2 ^openblas@0.3.24%clang@16.0.6~bignuma~consistent_fpcsr+fortran~ilp64+locking+pic+shared build_system=makefile symbol_suffix=none threads=none arch=darwin-macos-m1 -[+] xt3yny4 ^py-cython@0.29.36%clang@16.0.6 build_system=python_pip patches=c4369ad arch=darwin-macos-m1 -[+] jzgli7j ^py-pyproject-metadata@0.7.1%clang@16.0.6 build_system=python_pip arch=darwin-macos-m1 -[+] q7z5xrr ^py-pip@23.1.2%clang@16.0.6 build_system=generic arch=darwin-macos-m1 -[+] cjkvf75 ^py-pybind11@2.11.0%clang@16.0.6~ipo build_system=cmake build_type=Release generator=ninja arch=darwin-macos-m1 -[+] gy7mphw ^py-setuptools@68.0.0%clang@16.0.6 build_system=generic arch=darwin-macos-m1 -[+] wditibp ^py-setuptools-scm@8.0.4%clang@16.0.6+toml build_system=python_pip arch=darwin-macos-m1 -[e] o2wwfha ^git@2.39.5%clang@16.0.6+man+nls+perl+subtree~svn~tcltk build_system=autotools arch=darwin-macos-m1 -[+] athvzx3 ^py-packaging@23.1%clang@16.0.6 build_system=python_pip arch=darwin-macos-m1 -[+] aahjzwa ^py-flit-core@3.9.0%clang@16.0.6 build_system=python_pip arch=darwin-macos-m1 -[+] 63tk43p ^py-tomli@2.0.1%clang@16.0.6 build_system=python_pip arch=darwin-macos-m1 -[+] gcnx7k3 ^py-typing-extensions@4.8.0%clang@16.0.6 build_system=python_pip arch=darwin-macos-m1 -[+] prtzj2u ^py-wheel@0.41.2%clang@16.0.6 build_system=generic arch=darwin-macos-m1 -[+] j6zaiiu ^python@3.11.6%clang@16.0.6+bz2+crypt+ctypes+dbm~debug+libxml2+lzma~nis~optimizations+pic+pyexpat+pythoncmd+readline+shared+sqlite3+ssl~tkinter+uuid+zlib build_system=generic patches=13fa8bf,b0615b2,ebdca64,f2fd060 arch=darwin-macos-m1 -[e] ueihcfy ^apple-libuuid@1353.100.2%clang@16.0.6 build_system=bundle arch=darwin-macos-m1 -[+] 7ijbvg3 ^bzip2@1.0.8%clang@16.0.6~debug~pic+shared build_system=generic arch=darwin-macos-m1 -[+] bku3pxt ^diffutils@3.9%clang@16.0.6 build_system=autotools arch=darwin-macos-m1 -[+] qsg7k24 ^expat@2.5.0%clang@16.0.6~libbsd build_system=autotools arch=darwin-macos-m1 -[+] k3w6kae ^gdbm@1.23%clang@16.0.6 build_system=autotools arch=darwin-macos-m1 -[+] jnfyb2c ^gettext@0.22.3%clang@16.0.6+bzip2+curses+git~libunistring+libxml2+pic+shared+tar+xz build_system=autotools arch=darwin-macos-m1 -[+] hc4edf4 ^libiconv@1.17%clang@16.0.6 build_system=autotools libs=shared,static arch=darwin-macos-m1 -[+] u6jodzh ^libxml2@2.10.3%clang@16.0.6+pic~python+shared build_system=autotools arch=darwin-macos-m1 -[+] nyowhin ^tar@1.34%clang@16.0.6 build_system=autotools zip=pigz arch=darwin-macos-m1 -[+] 7t5dqak ^pigz@2.7%clang@16.0.6 build_system=makefile arch=darwin-macos-m1 -[+] rzlxhkd ^zstd@1.5.5%clang@16.0.6+programs build_system=makefile compression=none libs=shared,static arch=darwin-macos-m1 -[e] fhbmz3a ^libffi@3.4.4%clang@16.0.6 build_system=autotools arch=darwin-macos-m1 -[+] mt2inqh ^libxcrypt@4.4.35%clang@16.0.6~obsolete_api build_system=autotools patches=4885da3 arch=darwin-macos-m1 -[e] 3b4iznu ^openssl@3.4.0%clang@16.0.6~docs+shared build_system=generic certs=mozilla arch=darwin-macos-m1 -[+] uyiawy7 ^readline@8.2%clang@16.0.6 build_system=autotools patches=bbf97f1 arch=darwin-macos-m1 -[+] rhasc72 ^sqlite@3.43.2%clang@16.0.6+column_metadata+dynamic_extensions+fts~functions+rtree build_system=autotools arch=darwin-macos-m1 -[+] lg2cln5 ^xz@5.4.1%clang@16.0.6~pic build_system=autotools libs=shared,static arch=darwin-macos-m1 - -==> Updating view at /Users/katta/OBI/libsonata/spackenv/.spack-env/view From 03a5bbd04faeec10745e4a30291f04824ebb1520 Mon Sep 17 00:00:00 2001 From: Alessandro Cattabiani Date: Wed, 20 Aug 2025 19:27:27 +0200 Subject: [PATCH 8/8] address comments from ilkilic --- include/bbp/sonata/config.h | 2 +- src/config.cpp | 23 ++--------------------- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/include/bbp/sonata/config.h b/include/bbp/sonata/config.h index da776dd..dfaeae3 100644 --- a/include/bbp/sonata/config.h +++ b/include/bbp/sonata/config.h @@ -805,7 +805,7 @@ class SONATA_API SimulationConfig /** * Returns the name of the compartment set to be instantiated for the simulation, default = None */ - const nonstd::optional& getComaprtmentSet() const noexcept; + const nonstd::optional& getCompartmentSet() const noexcept; /** * Returns the metadata section diff --git a/src/config.cpp b/src/config.cpp index 87c561b..c4aee13 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -407,17 +407,6 @@ SimulationConfig::Input parseInputModule(const nlohmann::json& valueIt, parseOptional(valueIt, "node_set", input.nodeSet); parseOptional(valueIt, "compartment_set", input.compartmentSet); - const auto nodeSet = valueIt.find("node_set"); - const auto compartmentSet = valueIt.find("compartment_set"); - - if (nodeSet != valueIt.end()) { - parseOptional(valueIt, "node_set", input.nodeSet); - } - - if (compartmentSet != valueIt.end()) { - parseOptional(valueIt, "compartment_set", input.compartmentSet); - } - if (input.nodeSet.has_value() && input.compartmentSet.has_value()) { throw SonataError("`node_set` is not allowed if `compartment_set` is set in " + debugStr); @@ -487,16 +476,8 @@ SimulationConfig::Input parseInputModule(const nlohmann::json& valueIt, case Module::noise: { SimulationConfig::InputNoise ret; parseCommon(ret); - const auto mean = valueIt.find("mean"); - const auto mean_percent = valueIt.find("mean_percent"); - - if (mean != valueIt.end()) { - parseOptional(valueIt, "mean", ret.mean); - } - - if (mean_percent != valueIt.end()) { - parseOptional(valueIt, "mean_percent", ret.meanPercent); - } + parseOptional(valueIt, "mean", ret.mean); + parseOptional(valueIt, "mean_percent", ret.meanPercent); if (ret.mean.has_value() && ret.meanPercent.has_value()) { throw SonataError("Both `mean` or `mean_percent` have values in " + debugStr);