Skip to content

Commit

Permalink
Do not convert run_args values to lower case
Browse files Browse the repository at this point in the history
This broke setting values with arrays for group names with upper case characters
  • Loading branch information
mstimberg committed May 29, 2024
1 parent 03122f7 commit 538080a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
9 changes: 3 additions & 6 deletions brian2/devices/cpp_standalone/templates/objects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,10 @@ template<class T> void set_variable_from_file(std::string varname, T* var_pointe
void set_variable_by_name(std::string name, std::string s_value) {
size_t var_size;
size_t data_size;
std::for_each(s_value.begin(), s_value.end(), [](char& c) // modify in-place
{
c = std::tolower(static_cast<unsigned char>(c));
});
if (s_value == "true")
// C-style or Python-style capitalization is allowed for boolean values
if (s_value == "true" || s_value == "True")
s_value = "1";
else if (s_value == "false")
else if (s_value == "false" || s_value == "False")
s_value = "0";
// non-dynamic arrays
{% for var, varname in array_specs | dictsort(by='value') %}
Expand Down
2 changes: 1 addition & 1 deletion brian2/tests/test_cpp_standalone.py
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ def test_change_parameter_without_recompile_dict_syntax():
def test_change_synapse_parameter_without_recompile_dict_syntax():
set_device("cpp_standalone", directory=None, with_output=False)
G = NeuronGroup(10, "", name="neurons")
S = Synapses(G, G, "w:1", name="synapses")
S = Synapses(G, G, "w:1", name="Synapses")
S.connect(j="i")
S.w = np.arange(10)
run(0 * ms)
Expand Down

0 comments on commit 538080a

Please sign in to comment.