Skip to content

Commit 95b14c9

Browse files
Int replaced by floor to accept negative coordinates. (#3264)
--------- Co-authored-by: Robert A McDougal <robert.mcdougal@yale.edu>
1 parent 5fe797a commit 95b14c9

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

share/lib/python/neuron/rxd/node.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
_concentration_node = 0
3636
_molecule_node = 1
3737

38+
_floor = numpy.floor
39+
3840

3941
def _get_data():
4042
return (_volumes, _surface_area, _diffs)
@@ -650,9 +652,9 @@ def satisfies(self, condition):
650652
x, y, z = condition
651653
mesh = self._r._mesh_grid
652654
return (
653-
int((x - mesh["xlo"]) / mesh["dx"]) == self._i
654-
and int((y - mesh["ylo"]) / mesh["dy"]) == self._j
655-
and int((z - mesh["zlo"]) / mesh["dz"]) == self._k
655+
_floor((x - mesh["xlo"]) / mesh["dx"]) == self._i
656+
and _floor((y - mesh["ylo"]) / mesh["dy"]) == self._j
657+
and _floor((z - mesh["zlo"]) / mesh["dz"]) == self._k
656658
)
657659
# check for a position condition so as to provide a more useful error
658660
checked_for_normalized_position = False
@@ -885,8 +887,8 @@ def satisfies(self, condition):
885887
x, y, z = condition
886888
r = self._regionref()
887889
return (
888-
int((x - r._xlo) / r._dx[0]) == self._i
889-
and int((y - r._ylo) / r._dx[1]) == self._j
890-
and int((z - r._zlo) / r._dx[2]) == self._k
890+
_floor((x - r._xlo) / r._dx[0]) == self._i
891+
and _floor((y - r._ylo) / r._dx[1]) == self._j
892+
and _floor((z - r._zlo) / r._dx[2]) == self._k
891893
)
892894
raise RxDException(f"unrecognized node condition: {condition}")

test/rxd/3d/test_node_selection.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import weakref
2+
3+
14
def test_node_selection(neuron_instance):
25
"""Test selection of 3D nodes"""
36

@@ -16,4 +19,8 @@ def test_node_selection(neuron_instance):
1619
assert nodes((5.2, 0.1, 0.3))[0].x3d == 5.125
1720
assert nodes((5.2, 0.1, 0.3))[0].y3d == 0.125
1821
assert nodes((5.2, 0.1, 0.3))[0].z3d == 0.375
22+
23+
nodes.append(rxd.node.Node3D(0, -1, 0, 0, cyt, 0, dend(0.5), weakref.ref(c)))
24+
1925
assert len(nodes((5, 0, 0))) == 1
26+
assert nodes[-1] in nodes((nodes[-1].x3d, nodes[-1].y3d, nodes[-1].z3d))

0 commit comments

Comments
 (0)