Skip to content

Commit

Permalink
Merge pull request #1174 from hai-construction/ref/use-itemgetter-not…
Browse files Browse the repository at this point in the history
…-lambda

Use `operator.itemgetter` instead of a custom lambda in `ezdxf.math.rtree.box_split`
  • Loading branch information
mozman authored Oct 31, 2024
2 parents fa1c932 + d7c8f0d commit 75229f9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/ezdxf/math/rtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# - Research paper of Antonin Guttman:
# http://www-db.deis.unibo.it/courses/SI-LS/papers/Gut84.pdf
from __future__ import annotations
from operator import itemgetter
import statistics
from typing import Iterator, Callable, Sequence, Iterable, TypeVar, Generic
import abc
Expand Down Expand Up @@ -260,7 +261,7 @@ def box_split(points: list[T], max_size: int) -> Sequence[Node[T]]:
n = len(points)
size: tuple[float, float, float] = BoundingBox(points).size.xyz
dim = size.index(max(size))
points.sort(key=lambda vec: vec[dim])
points.sort(key=itemgetter(dim))
k = math.ceil(n / max_size)
return tuple(
make_node(points[i : i + k], max_size, box_split) for i in range(0, n, k)
Expand Down

0 comments on commit 75229f9

Please sign in to comment.