Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use operator.itemgetter instead of a custom lambda in ezdxf.math.rtree.box_split #1174

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
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