Skip to content

Commit 17bb25c

Browse files
committed
Fix push_both, update version number
1 parent 4155250 commit 17bb25c

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

numba_celltree/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from numba_celltree.celltree import CellTree2d
22

3-
__version__ = "0.2.0"
3+
__version__ = "0.2.1"
44

55
__all__ = ("CellTree2d",)

numba_celltree/constants.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,7 @@ class CellTreeData(NamedTuple):
142142
# that can be included is given by 2 ** (depth of stack - 1).
143143
# (int(math.ceil(math.log(MAX_N_FACE, 2))) + 1)
144144
# This is only true for relatively balanced trees. MAX_N_FACE = int(2e9)
145-
# results in required stack of 32. 128 suffices for some more degenerate input
146-
# (triangulation result of complex polygon earcuts).
145+
# results in required stack of 32.
147146
INITIAL_TREE_DEPTH = 32
148147
# Floating point slack
149148
TOLERANCE_ON_EDGE = 1e-9

numba_celltree/creation.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,8 @@ def pessimistic_n_nodes(n_polys: int):
230230
@nb.njit(inline="always")
231231
def push_both(root_stack, dim_stack, root, dim, size):
232232
root_stack, size_root = push(root_stack, root, size)
233-
_, _ = push(dim_stack, dim, size)
234-
return size_root
233+
dim_stack, _ = push(dim_stack, dim, size)
234+
return root_stack, dim_stack, size_root
235235

236236

237237
@nb.njit(inline="always")
@@ -361,7 +361,9 @@ def build(
361361
if dim_flag >= 0:
362362
dim_flag = (not dim) - 2
363363
nodes[root_index]["dim"] = not root.dim
364-
size = push_both(root_stack, dim_stack, root_index, dim_flag, size)
364+
root_stack, dim_stack, size = push_both(
365+
root_stack, dim_stack, root_index, dim_flag, size
366+
)
365367
else: # Already split once, convert to leaf.
366368
nodes[root_index]["Lmax"] = -1
367369
nodes[root_index]["Rmin"] = -1
@@ -387,8 +389,12 @@ def build(
387389
node_index = push_node(nodes, left_child, node_index)
388390
node_index = push_node(nodes, right_child, node_index)
389391

390-
size = push_both(root_stack, dim_stack, child_ind + 1, right_child.dim, size)
391-
size = push_both(root_stack, dim_stack, child_ind, left_child.dim, size)
392+
root_stack, dim_stack, size = push_both(
393+
root_stack, dim_stack, child_ind + 1, right_child.dim, size
394+
)
395+
root_stack, dim_stack, size = push_both(
396+
root_stack, dim_stack, child_ind, left_child.dim, size
397+
)
392398

393399
return node_index
394400

tests/test_utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ def test_push_size_increases():
3737
stack, size = ut.push(stack, 1, size)
3838
assert stack.size == 2
3939
assert size_before < stack.size
40+
stack, size = ut.push(stack, 10, size)
41+
assert stack.size == 4
42+
assert np.array_equal(stack[:3], [0, 1, 10])
4043

4144

4245
def test_copy():

0 commit comments

Comments
 (0)