Skip to content

Commit b20f29f

Browse files
authored
Merge pull request #10 from paradoxysm/release
0.1.7 Release to Production
2 parents a4045b8 + b75eddf commit b20f29f

22 files changed

+333
-423
lines changed

.coveragerc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[report]
2+
exclude_lines =
3+
raise NotImplementedError

.github/PULL_REQUEST_TEMPLATE/pull_request_template.md .github/PULL_REQUEST_TEMPLATE.md

+4-12
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
1-
---
2-
name: Pull request
3-
about: Propose a pull request
4-
title: ''
5-
labels: ''
6-
assignees: ''
7-
8-
---
9-
101
Please assign an appropriate label to the PR:
11-
- bug : This PR fixes a bug
12-
- documentation : This PR improves on the documentation
13-
- enhancement : This PR implements a new feature or enhancement
2+
- bug : This PR fixes a bug.
3+
- documentation : This PR improves on the documentation.
4+
- enhancement : This PR implements a new feature or enhancement.
5+
- release : This PR is a release PR to the `release` branch.
146

157
**Reference Issues/PRs where applicable**
168

CHANGES.md

+13
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,19 @@
99
- ![Documentation](https://img.shields.io/badge/-Documentation-blue) : An update to the documentation.
1010
- ![Other](https://img.shields.io/badge/-Other-lightgrey) : Miscellaneous updates such as package structure or GitHub quality of life updates.
1111

12+
13+
### Version 0.1.7
14+
15+
- ![Feature](https://img.shields.io/badge/-Feature-blueviolet) : [`_utils.format_array`](https://github.com/paradoxysm/kdtrees/blob/0.1.7/kdtrees/_utils.py) is now removed and all code is changed to reflect. **This is a major feature. `kdtrees 0.1.7` is not backwards-compatible.**
16+
- ![Enhancement](https://img.shields.io/badge/-Enhancement-purple) : `__len__` no longer a required function in [`KDTreeType`](https://github.com/paradoxysm/kdtrees/blob/0.1.7/kdtrees/_kdtree_type.py) as per [ISS #9](https://github.com/paradoxysm/kdtrees/issues/9).
17+
- ![Fix](https://img.shields.io/badge/-Fix-red) : [`_kdtrees.initialize`](https://github.com/paradoxysm/kdtrees/blob/0.1.7/kdtrees/_kdtrees.py) now correctly handles `accept` overrides to update presorted arrays.
18+
- ![Fix](https://img.shields.io/badge/-Fix-red) : [`_utils.check_dimensionality`](https://github.com/paradoxysm/kdtrees/blob/0.1.7/kdtrees/_utils.py) now properly checks `accept` overridden types without unexepected errors.
19+
- ![Fix](https://img.shields.io/badge/-Fix-red) : [`KDTreeType`](https://github.com/paradoxysm/kdtrees/blob/0.1.7/kdtrees/_kdtree_type.py) now implements `__lt__` for proper sorting.
20+
- ![Fix](https://img.shields.io/badge/-Fix-red) : [`KDTreeType`](https://github.com/paradoxysm/kdtrees/blob/0.1.7/kdtrees/_kdtree_type.py) no longer extends `list` so that it can be properly wrapped into a list.
21+
- ![Fix](https://img.shields.io/badge/-Fix-red) : [`_kdtrees.nearest_neighbor`](https://github.com/paradoxysm/kdtrees/blob/0.1.7/kdtrees/_kdtrees.py) and [`_kdtrees.proximal_neighbor`](https://github.com/paradoxysm/kdtrees/blob/0.1.7/kdtrees/_kdtrees.py) now properly call [`_utils.distance`](https://github.com/paradoxysm/kdtrees/blob/0.1.7/kdtrees/_utils.py) with `accept` override applied as per [ISS #7](https://github.com/paradoxysm/kdtrees/issues/7).
22+
- ![Documentation](https://img.shields.io/badge/-Documentation-blue) : Updated documentation to reflect changes.
23+
- ![Documentation](https://img.shields.io/badge/-Documentation-blue) : Implemented a number of new tests in [`tests`](https://github.com/paradoxysm/kdtrees/tree/0.1.7/tests/)
24+
1225
### Version 0.1.6
1326

1427
- ![Enhancement](https://img.shields.io/badge/-Enhancement-purple) : `__iter__` no longer required for [`KDTreeType`](https://github.com/paradoxysm/kdtrees/blob/0.1.6/kdtrees/_kdtree_type.py) as per [ISS #2](https://github.com/paradoxysm/kdtrees/issues/2).

README.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ A K-Dimensional Tree, or K-D Tree, is a space-partitioning data structure which
1616

1717
kdtrees implementation of a K-D Tree allows for construction, modification, searching, and other helpful functions such as k-nearest neighbors. It also maintains the tree in a pseudo-balanced manner through a secondary invariant where every node is the median ± dimensionality of subsidiary nodes along a specific axis.
1818

19-
More details regarding this implementation can be found in the documentation [here](https://github.com/paradoxysm/kdtrees/tree/master/doc).
19+
More details regarding this implementation can be found in the documentation [here](https://github.com/paradoxysm/kdtrees/tree/0.1.7/doc).
2020

2121
## Installation
2222

@@ -37,19 +37,21 @@ pip install kdtrees
3737

3838
## Changelog
3939

40-
See the [changelog](https://github.com/paradoxysm/kdtrees/tree/master/CHANGES.md) for a history of notable changes to kdtrees.
40+
See the [changelog](https://github.com/paradoxysm/kdtrees/blob/0.1.7/CHANGES.md) for a history of notable changes to kdtrees.
4141

4242
## Development
4343

4444
kdtrees is fully implemented for basic functionality. However, it may not have every utility function or have the most optimized algorithms. We welcome contributors of all experience levels to help grow and improve kdtrees. Guides on development, testing, and contribution are in the works!
4545

4646
Currently, particular contributions regarding pytests and documentation would be greatly appreciated. Guides and examples of usage are warmly welcomed.
4747

48+
There are three main branches for development and release. `master` is the current development build; `release` is the staging branch for releases; `production` is the current public release build.
49+
4850
## Help and Support
4951

5052
### Documentation
5153

52-
Documentation for kdtrees can be found [here](https://github.com/paradoxysm/kdtrees/tree/master/doc).
54+
Documentation for kdtrees can be found [here](https://github.com/paradoxysm/kdtrees/tree/0.1.7/doc).
5355

5456
### Issues and Questions
5557

doc/README.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
All documentation for kdtrees is located here!
44

5-
[**pydoc**](https://github.com/paradoxysm/kdtrees/tree/master/doc/pydoc) : Documentation regarding python classes and functions.
5+
[**pydoc**](https://github.com/paradoxysm/kdtrees/tree/0.1.7/doc/pydoc) : Documentation regarding python classes and functions.
66

77
# KDTrees Overview
88

@@ -14,7 +14,7 @@ kdtrees supports all builtin types and numpy types. However, additional support
1414

1515
**Construction**
1616

17-
kdtrees constructs a K-D Tree from a given list of points in a manner such that a pseudo-balanced tree is produced (i.e. A tree that satisfies the secondary invariant). It does this by presorting the list of points along each of the available axes. At each recursive entry, the median point along an alternating axis of discrimination is chosen as the root of the sub-tree. This produces a pseudo-balanced tree in *O(nlogn)*. For details see [`initialize`](https://github.com/paradoxysm/kdtrees/tree/master/doc/pydoc/doc_kdtree.md#initialize).
17+
kdtrees constructs a K-D Tree from a given list of points in a manner such that a pseudo-balanced tree is produced (i.e. A tree that satisfies the secondary invariant). It does this by presorting the list of points along each of the available axes. At each recursive entry, the median point along an alternating axis of discrimination is chosen as the root of the sub-tree. This produces a pseudo-balanced tree in *O(nlogn)*. For details see [`initialize`](https://github.com/paradoxysm/kdtrees/blob/0.1.7/doc/pydoc/doc_kdtree.md#initialize).
1818

1919
**Visualization**
2020

@@ -29,28 +29,28 @@ kdtrees can be visualized in a preorder traversal. This is one such example:
2929
None
3030
None
3131
```
32-
For details see [`visualize`](https://github.com/paradoxysm/kdtrees/tree/master/doc/pydoc/doc_kdtree.md#visualize).
32+
For details see [`visualize`](https://github.com/paradoxysm/kdtrees/blob/0.1.7/doc/pydoc/doc_kdtree.md#visualize).
3333

3434
**Insertion and Deletion**
3535

36-
kdtrees supports insertion and deletion in preorder traversal. The tree automatically balances as needed. It runs in *O(logn)*. For details see [`insert`](https://github.com/paradoxysm/kdtrees/tree/master/doc/pydoc/doc_kdtree.md#insert) and [`delete`](https://github.com/paradoxysm/kdtrees/tree/master/doc/pydoc/doc_kdtree.md#delete).
36+
kdtrees supports insertion and deletion in preorder traversal. The tree automatically balances as needed. It runs in *O(n)*. For details see [`insert`](https://github.com/paradoxysm/kdtrees/blob/0.1.7/doc/pydoc/doc_kdtree.md#insert) and [`delete`](https://github.com/paradoxysm/kdtrees/blob/0.1.7/doc/pydoc/doc_kdtree.md#delete).
3737

3838
**Searching**
3939

40-
kdtrees supports searches in preorder traversal, running in *O(logn)*. kdtrees searches and produces the KDTree that holds the queried value. Finding none, it will return None. For details see [`search`](https://github.com/paradoxysm/kdtrees/tree/master/doc/pydoc/doc_kdtree.md#search).
40+
kdtrees supports searches in preorder traversal, running in *O(logn)*. kdtrees searches and produces the KDTree that holds the queried value. Finding none, it will return None. For details see [`search`](https://github.com/paradoxysm/kdtrees/blob/0.1.7/doc/pydoc/doc_kdtree.md#search).
4141

4242
**Aggregating**
4343

44-
kdtrees can aggregate all subsidiary nodes, produced as a list in preorder, running in *O(logn)*. For details see [`collect`](https://github.com/paradoxysm/kdtrees/tree/master/doc/pydoc/doc_kdtree.md#collect).
44+
kdtrees can aggregate all subsidiary nodes, produced as a list in preorder, running in *O(logn)*. For details see [`collect`](https://github.com/paradoxysm/kdtrees/blob/0.1.7/doc/pydoc/doc_kdtree.md#collect).
4545

4646
**Balancing**
4747

48-
kdtrees balances in a pseudo-balanced manner, satisfying the secondary invariant. If the KDTree does not satisfy this invariant, it is reconstructed anew and thus returned to pseudo-balance. For details see [`balance`](https://github.com/paradoxysm/kdtrees/tree/master/doc/pydoc/doc_kdtree.md#balance).
48+
kdtrees balances in a pseudo-balanced manner, satisfying the secondary invariant. If the KDTree does not satisfy this invariant, it is reconstructed anew and thus returned to pseudo-balance. For details see [`balance`](https://github.com/paradoxysm/kdtrees/blob/0.1.7/doc/pydoc/doc_kdtree.md#balance).
4949

5050
**K-Nearest Neighbors**
5151

52-
kdtrees supports finding k-nearest neighbors, finding a specified number of (1 if not specified) of nodes that are closest to the query point. Ties are broken based on the preorder traversal (i.e. left-most nodes are prioritized). It produces a list of tuples, containing the value of the node and its corresponding distance to the query point. For details see [`nearest_neighbor`](https://github.com/paradoxysm/kdtrees/tree/master/doc/pydoc/doc_kdtree.md#nearest_neighbor).
52+
kdtrees supports finding k-nearest neighbors, finding a specified number of (1 if not specified) of nodes that are closest to the query point. Ties are broken based on the preorder traversal (i.e. left-most nodes are prioritized). It produces a list of tuples, containing the value of the node and its corresponding distance to the query point. For details see [`nearest_neighbor`](https://github.com/paradoxysm/kdtrees/blob/0.1.7/doc/pydoc/doc_kdtree.md#nearest_neighbor).
5353

5454
**Neighbors-within-Distance**
5555

56-
kdtrees is also able to find all neighbors within a specified distance (0 if not specified). This produces a list of tuples, containing the value of the node and its corresponding distance to the query point. For details see [`proximal_neighbor`](https://github.com/paradoxysm/kdtrees/tree/master/doc/pydoc/doc_kdtree.md#proximal_neighbor).
56+
kdtrees is also able to find all neighbors within a specified distance (0 if not specified). This produces a list of tuples, containing the value of the node and its corresponding distance to the query point. For details see [`proximal_neighbor`](https://github.com/paradoxysm/kdtrees/blob/0.1.7/doc/pydoc/doc_kdtree.md#proximal_neighbor).

doc/pydoc/doc_kdtree.md

+24-15
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ median ± dimensionality of all nodes contained in the KDTree.
1212

1313
**Parameters**
1414
```
15-
value : array-like
15+
value : array-like or object
1616
Value at the KDTree node.
1717
1818
k : int, default=0
@@ -34,6 +34,9 @@ right : KDTree
3434
3535
nodes : int
3636
Number of nodes in the KDTree, including itself.
37+
38+
accept : KDTreeType or None
39+
Override and allow a custom type to be accepted.
3740
```
3841

3942
## initialize
@@ -49,22 +52,23 @@ as the root.
4952
**Parameters**
5053
```
5154
points : array-like, shape (n_points, *)
52-
List of points to build a KDTree where the last axis denotes the features
55+
List of points to build a KDTree where the last axis denotes the features.
56+
If `accept` is a KDTreeType, list can contain this type.
5357
5458
k : int or None, default=None
55-
Dimensionality of the points. If None, `initialize` will self-detect.
59+
Dimensionality of the points. If None, `initialize` will self-detect.
5660
5761
init_axis : int, default=0
58-
Initial axis to generate the KDTree.
62+
Initial axis to generate the KDTree.
5963
6064
accept : KDTreeType or None
61-
Override and allow custom types to be accepted.
65+
Override and allow a custom type to be accepted.
6266
```
6367

6468
**Returns**
6569
```
6670
tree : KDTree
67-
The root of the KDTree built from `points`
71+
The root of the KDTree built from `points`.
6872
```
6973

7074
## visualize
@@ -90,7 +94,8 @@ Insert a point into the KDTree.
9094
**Parameters**
9195
```
9296
point : array-like or scalar
93-
The point to be inserted, where the last axis denotes the features.
97+
The point (KDTreeType if `accept` is used) to be inserted,
98+
where the last axis denotes the features.
9499
```
95100

96101
**Returns**
@@ -110,7 +115,8 @@ Returns the KDTree node if found, None otherwise.
110115
**Parameters**
111116
```
112117
point : array-like or scalar
113-
The point being searched, where the last axis denotes the features.
118+
The point (KDTreeType if `accept` is used) being searched,
119+
where the last axis denotes the features.
114120
```
115121

116122
**Returns**
@@ -131,7 +137,8 @@ KDTree. Returns the same tree if the point was not found.
131137
**Parameters**
132138
```
133139
point : array-like or scalar
134-
The point to be deleted, where the last axis denotes the features.
140+
The point (KDTreeType if `accept` is used) to be deleted,
141+
where the last axis denotes the features.
135142
```
136143

137144
**Returns**
@@ -190,20 +197,21 @@ Determine the `n` nearest KDTree nodes to `point` and their distances.
190197
**Parameters**
191198
```
192199
point : array-like or scalar
193-
The query point, where the last axis denotes the features.
200+
The query point (KDTreeType if `accept` is used),
201+
where the last axis denotes the features.
194202
195203
n : int, default=1
196204
The number of neighbors to search for.
197205
198-
neighbors : list, default=[]
206+
neighbors : array-like, default=[]
199207
The list of `n` tuples, referring to `n` nearest neighbors,
200208
sorted based on proximity. The first value in the tuple is the
201209
point, while the second is the distance to `point`.
202210
```
203211

204212
**Returns**
205213
```
206-
neighbors : list, shape (n_neighbors, 2)
214+
neighbors : ndarray, shape (n_neighbors, 2)
207215
The list of `n` tuples, referring to `n` nearest neighbors.
208216
```
209217

@@ -218,12 +226,13 @@ to `point` and their distances.
218226
**Parameters**
219227
```
220228
point : array-like or scalar
221-
The query point, where the last axis denotes the features.
229+
The query point (KDTreeType if `accept` is used),
230+
where the last axis denotes the features.
222231
223232
d : int, default=0
224233
The maximum acceptable distance for neighbors.
225234
226-
neighbors : list, default=[]
235+
neighbors : array-like, default=[]
227236
The list of `n` tuples, referring to proximal neighbors within
228237
`d` distance from `point`, sorted based on proximity.
229238
The first value in the tuple is the point, while the
@@ -232,7 +241,7 @@ neighbors : list, default=[]
232241

233242
**Returns**
234243
```
235-
neighbors : list, shape (n_neighbors, 2)
244+
neighbors : ndarray, shape (n_neighbors, 2)
236245
The list of `n` tuples, referring to proximal neighbors within
237246
`d` distance from `point`.
238247
```

doc/pydoc/doc_kdtree_type.md

+12-7
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,23 @@ ne : bool
5656
True if `other` is not equivalent to this `KDTreeType`
5757
```
5858

59-
## __len__
59+
## __lt__
6060
```python
61-
len(KDTreeType)
62-
KDTreeType.__len__()
61+
KDTreeType < KDTreeType
62+
KDTreeType.__lt__(other)
63+
```
64+
Return if this `KDTreeType` is 'less' than `other`.
65+
66+
**Parameters**
67+
```
68+
other : object
69+
The object in question.
6370
```
64-
Return the 'length' of the KDTreeType. This needs to be
65-
defined based on the custom implementation.
6671

6772
**Returns**
6873
```
69-
length : int
70-
The 'length' of this `KDTreeType`.
74+
lt : bool
75+
True if this `KDTreeType` is 'less' than `other`.
7176
```
7277

7378
## __getitem__

doc/pydoc/doc_utils.md

+13-41
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,9 @@
11
# kdtrees._utils
22
Utilities for Various Tasks
3-
## format_array
4-
```python
5-
format_array(arr, l=False, accept=None)
6-
```
7-
8-
Format the given array or scalar into a numpy ndarray
9-
such that the last axis denotes the features.
10-
If the argument given is a scalar, wrap into a list first.
11-
12-
**Parameters**
13-
```
14-
arr : array-like or scalar
15-
Array-like object or scalar to convert into ndarray.
16-
17-
l : bool
18-
`l` should be set to True if `arr` is semantically a list of items.
19-
20-
accept : None or object, default=None
21-
Accept override type. Allow `arr` to be this type
22-
```
23-
24-
**Returns**
25-
```
26-
ndarr : ndarray
27-
Formatted ndarray where the last axis denotes the features.
28-
```
293

304
## check_dimensionality
315
```python
32-
check_dimensionality(*args, l=False, accept=None)
6+
check_dimensionality(*args, accept=None)
337
```
348

359
Check that all arguments have the same dimensionality.
@@ -41,14 +15,11 @@ attribute, use that instead.
4115
**Parameters**
4216
```
4317
*args : tuple, default=()
44-
Tuple of array-like objects where the last axis denotes the features.
45-
46-
l : bool
47-
`l` should be set to True if `args` is a tuple where every
48-
item is semantically a list of items.
18+
Tuple of ndarray objects where the last axis denotes the features.
19+
If `accept` is an object, it can be this type.
4920
5021
accept : None or object, default=None
51-
Accept override type. Check the `dim` attribute of this object
22+
Accept override type. Check the `dim` attribute of this object.
5223
```
5324

5425
**Returns**
@@ -69,19 +40,20 @@ function, use that instead. Uses `obj1.distance(obj2)`.
6940

7041
**Parameters**
7142
```
72-
obj1 : array-like or object, default=()
73-
Tuple of array-like objects where the last axis denotes the features.
43+
obj1 : array-like or scalar or object
44+
array-like or scalar where the last axis denotes the features.
45+
If `accept` is an object, it can be this type.
7446
75-
l : bool
76-
`l` should be set to True if `args` is a tuple where every
77-
item is semantically a list of items.
47+
obj2 : array-like or scalar or object
48+
array-like or scalar where the last axis denotes the features.
49+
If `accept` is an object, it can be this type.
7850
7951
accept : None or object, default=None
80-
Accept override type. Check the dimensionality attribute of this object
52+
Accept override type. Use the `distance` function of this type.
8153
```
8254

8355
**Returns**
8456
```
85-
dim : int
86-
The dimensionality of all given arguments.
57+
distance : int
58+
The distance between `obj1` and `obj2`.
8759
```

0 commit comments

Comments
 (0)