diff --git a/share/lib/python/neuron/rxd/node.py b/share/lib/python/neuron/rxd/node.py index 518d89543c..d3cfe8d981 100644 --- a/share/lib/python/neuron/rxd/node.py +++ b/share/lib/python/neuron/rxd/node.py @@ -35,6 +35,8 @@ _concentration_node = 0 _molecule_node = 1 +_floor = numpy.floor + def _get_data(): return (_volumes, _surface_area, _diffs) @@ -650,9 +652,9 @@ def satisfies(self, condition): x, y, z = condition mesh = self._r._mesh_grid return ( - int((x - mesh["xlo"]) / mesh["dx"]) == self._i - and int((y - mesh["ylo"]) / mesh["dy"]) == self._j - and int((z - mesh["zlo"]) / mesh["dz"]) == self._k + _floor((x - mesh["xlo"]) / mesh["dx"]) == self._i + and _floor((y - mesh["ylo"]) / mesh["dy"]) == self._j + and _floor((z - mesh["zlo"]) / mesh["dz"]) == self._k ) # check for a position condition so as to provide a more useful error checked_for_normalized_position = False @@ -885,8 +887,8 @@ def satisfies(self, condition): x, y, z = condition r = self._regionref() return ( - int((x - r._xlo) / r._dx[0]) == self._i - and int((y - r._ylo) / r._dx[1]) == self._j - and int((z - r._zlo) / r._dx[2]) == self._k + _floor((x - r._xlo) / r._dx[0]) == self._i + and _floor((y - r._ylo) / r._dx[1]) == self._j + and _floor((z - r._zlo) / r._dx[2]) == self._k ) raise RxDException(f"unrecognized node condition: {condition}") diff --git a/test/rxd/3d/test_node_selection.py b/test/rxd/3d/test_node_selection.py index 52a21424fd..9ca3ab8ff7 100644 --- a/test/rxd/3d/test_node_selection.py +++ b/test/rxd/3d/test_node_selection.py @@ -1,3 +1,6 @@ +import weakref + + def test_node_selection(neuron_instance): """Test selection of 3D nodes""" @@ -16,4 +19,8 @@ def test_node_selection(neuron_instance): assert nodes((5.2, 0.1, 0.3))[0].x3d == 5.125 assert nodes((5.2, 0.1, 0.3))[0].y3d == 0.125 assert nodes((5.2, 0.1, 0.3))[0].z3d == 0.375 + + nodes.append(rxd.node.Node3D(0, -1, 0, 0, cyt, 0, dend(0.5), weakref.ref(c))) + assert len(nodes((5, 0, 0))) == 1 + assert nodes[-1] in nodes((nodes[-1].x3d, nodes[-1].y3d, nodes[-1].z3d))