Skip to content

Commit

Permalink
fixed the leafsize annotation and default value
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Luca van den Busch committed Jan 31, 2024
1 parent 9d01e29 commit 4b0c113
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions balltree/angulartree.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,16 @@ def from_random(
dec_min: float,
dec_max: float,
size: int,
leafsize: int | None = None
leafsize: int = default_leafsize
) -> AngularTree:
"""
Build a new AngularTree instance from randomly generated points.
The (ra, dec) coordinates are generated uniformly in the interval
[`ra_min`, `ra_max`) and [`dec_min`, `dec_max`), respectively. `size`
controlls the number of points generated. The optional `leafsize` sets
the leaf size of the tree.
controlls the number of points generated. The optional `leafsize`
determines when the tree query algorithms switch from traversal to brute
force.
"""
((x_min, y_min),) = coord.angular_to_cylinder([ra_min, dec_min])
((x_max, y_max),) = coord.angular_to_cylinder([ra_max, dec_max])
Expand Down
7 changes: 4 additions & 3 deletions balltree/balltree.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
PyDoc_STRVAR(
// .. py:class::
balltree_doc,
"BallTree(xyz: ArrayLike, weight: ArrayLike | None = None, leafsize: int | None = None)\n\n"
"BallTree(xyz: ArrayLike, weight: ArrayLike | None = None, leafsize: int = default_leafsize)\n\n"
"A wrapper for the `C` implementation of BallTree.\n\n"
"The tree is implemented for 3-dim coordinates and an Euclidean distance\n"
"metric. It provides different alorigthms to count neighbours within a\n"
Expand Down Expand Up @@ -608,12 +608,13 @@ PyDoc_STRVAR(
// .. py:method::
// :classmethod:
from_random_doc,
"from_random(cls, low: float, high: float, size: int, leafsize: int | None = None) -> BallTree\n"
"from_random(cls, low: float, high: float, size: int, leafsize: int = default_leafsize) -> BallTree\n"
"--\n\n"
"Build a new BallTree instance from randomly generated points.\n\n"
"The (x, y, z) coordinates are generated uniformly in the interval\n"
"[`low`, `high`), `size` controlls the number of points generated. The\n"
"optional `leafsize` sets the leaf size of the tree."
"optional `leafsize` determines when the tree query algorithms switch from\n"
"traversal to brute force."
);

static PyObject *PyBallTree_from_random(
Expand Down

0 comments on commit 4b0c113

Please sign in to comment.