Skip to content

Commit

Permalink
fixed failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jackd committed May 11, 2020
1 parent 82014e9 commit 9fcf8b6
Show file tree
Hide file tree
Showing 11 changed files with 103 additions and 164 deletions.
21 changes: 21 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[MESSAGES CONTROL]

disable=
bad-continuation,
bad-whitespace,
invalid-name,
missing-module-docstring,
missing-class-docstring,
missing-function-docstring,
redefined-outer-name,
c-extension-no-member,
too-many-arguments,
too-many-instance-attributes,
too-many-locals,
invalid-unary-operand-type,
not-context-manager,
redefined-builtin

[format]

max-line-length=88
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,23 @@ You may see performance benefits from `fastmath` by installing Intel's short vec
conda install -c numba icc_rt
```

## Debugging

Debugging is often simpler without `jit`ting. To disable `numba`,

```bash
export NUMBA_DISABLE_JIT=1
```

and re-enable with

```bash
export NUMBA_DISABLE_JIT=0
```

Be wary of using `os.environ["NUMBA_DISABLE_JIT"] = "1"` from python code - this must be set above imports.


## Differences compared to Scikit-learn

1. All operations are done using reduced distances. E.g. provided `KDTree` implementations use squared distances rather than actual distances both for inputs and outputs.
Expand Down
7 changes: 1 addition & 6 deletions example/compare_ifp.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import os

import numpy as np

from numba_neighbors import binary_tree as bt
from numba_neighbors import kd_tree as kd

os.environ["NUMBA_DISABLE_JIT"] = "1"


N = 100
n = 50
D = 1
Expand All @@ -20,7 +15,7 @@

np.random.seed(124)
data = np.random.uniform(size=(N, D)).astype(kd.FLOAT_TYPE)
# data.sort(axis=0)
data.sort(axis=0)
print(data)

tree = kd.KDTree(data, leaf_size=leaf_size)
Expand Down
19 changes: 4 additions & 15 deletions example/ifp_sample.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import os

import matplotlib.pyplot as plt
import numpy as np

from numba_neighbors import kd_tree as kd

os.environ["NUMBA_DISABLE_JIT"] = "1"


N = 1024
n = 256
n = 70
D = 2
# rejection_r = 0.1
query_r = 0.1
Expand All @@ -22,7 +17,7 @@
data = np.random.uniform(size=(N, D)).astype(kd.FLOAT_TYPE)

tree = kd.KDTree(data, leaf_size=leaf_size)
sample_result, query_result = tree.ifp_sample_query(
sample_result0, query_result0 = tree.ifp_sample_query(
r2, tree.get_node_indices(), n, max_neighbors
)
sample_result, query_result = tree.rejection_ifp_sample_query(
Expand All @@ -31,13 +26,7 @@


def vis(
x0,
sample_indices,
query_result,
small_balls=True,
big_balls=False,
labels=False,
aspect=1,
x0, sample_indices, query_result, small_balls=True, big_balls=False, labels=False,
):
x1 = x0[sample_indices]
xn = x0[query_result.indices[0, : query_result.counts[0]]]
Expand Down Expand Up @@ -69,5 +58,5 @@ def vis(
ax.set_aspect(1)


vis(data, sample_result.indices, query_result)
vis(data, sample_result.indices, query_result, big_balls=False)
plt.show()
5 changes: 0 additions & 5 deletions example/index_heap.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import os

import numpy as np

from numba_neighbors.index_heap import padded_index_heap

os.environ["NUMBA_DISABLE_JIT"] = "1"


heap = padded_index_heap(np.zeros((10,)), np.arange(10), 20)
print(heap.pop())
print(heap.pop())
Expand Down
4 changes: 0 additions & 4 deletions example/rejection_ifp_sample.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import os

import matplotlib.pyplot as plt
import numpy as np

from numba_neighbors import kd_tree as kd

os.environ["NUMBA_DISABLE_JIT"] = "1"

N = 1024
n = 128
D = 2
Expand Down
5 changes: 0 additions & 5 deletions example/rejection_sample.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import os

import matplotlib.pyplot as plt
import numpy as np

from numba_neighbors import kd_tree as kd

os.environ["NUMBA_DISABLE_JIT"] = "1"


N = 1024
n = N
D = 2
Expand Down
Loading

0 comments on commit 9fcf8b6

Please sign in to comment.