Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions share/lib/python/neuron/rxd/rxdmath.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@
pass
return False

def _semi_compile(self, region, instruction):

Check failure on line 743 in share/lib/python/neuron/rxd/rxdmath.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this function to reduce its Cognitive Complexity from 19 to the 15 allowed.

See more on https://sonarcloud.io/project/issues?id=neuronsimulator_nrn&issues=AZ78RUCvv2bAtrO4ixwf&open=AZ78RUCvv2bAtrO4ixwf&pullRequest=3808
items = []
counts = []
items_append = items.append
Expand All @@ -750,6 +750,8 @@
try:
items_append(item._semi_compile(region, instruction))
except AttributeError:
if isinstance(item, numpy.generic):
item = item.item()
items_append(f"{item!r}")
counts_append(count)
result = ""
Expand Down
15 changes: 15 additions & 0 deletions test/rxd/test_state_reaction.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest
import numpy as np
from .testutils import compare_data, tol


Expand Down Expand Up @@ -37,3 +38,17 @@
h.finitialize(-65)
h.continuerun(1)
assert sec(0.5).ca2i == sec(0.5).cai


def test_numpy_rate(neuron_instance):
"""Test a simple rxd.Rate involving a numpy value"""
n, rxd, data, save_path = neuron_instance

Check warning on line 45 in test/rxd/test_state_reaction.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace the unused local variable "data" with "_".

See more on https://sonarcloud.io/project/issues?id=neuronsimulator_nrn&issues=AZ78e3wYADioH-cLUXZP&open=AZ78e3wYADioH-cLUXZP&pullRequest=3808

Check warning on line 45 in test/rxd/test_state_reaction.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace the unused local variable "save_path" with "_".

See more on https://sonarcloud.io/project/issues?id=neuronsimulator_nrn&issues=AZ78e3wYADioH-cLUXZQ&open=AZ78e3wYADioH-cLUXZQ&pullRequest=3808
soma = n.Section("soma")
soma.L = soma.diam = 10
cyt = rxd.Region([soma], name="cyt", nrn_region="i")
c = rxd.Species(cyt, name="c", charge=1, initial=0)
r = rxd.Rate(c, np.float64(1))

Check warning on line 50 in test/rxd/test_state_reaction.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove the unused local variable "r".

See more on https://sonarcloud.io/project/issues?id=neuronsimulator_nrn&issues=AZ78e3wYADioH-cLUXZO&open=AZ78e3wYADioH-cLUXZO&pullRequest=3808
n.dt = 0.025
n.finitialize(-65)
n.fadvance()
assert c.nodes[0].concentration == 0.025

Check warning on line 54 in test/rxd/test_state_reaction.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Do not perform equality checks with floating point values.

See more on https://sonarcloud.io/project/issues?id=neuronsimulator_nrn&issues=AZ78e3wYADioH-cLUXZR&open=AZ78e3wYADioH-cLUXZR&pullRequest=3808
Loading