Skip to content

Commit 58e5d27

Browse files
committed
Lint tests
1 parent 5ccda74 commit 58e5d27

File tree

5 files changed

+38
-11
lines changed

5 files changed

+38
-11
lines changed

pyproject.toml

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,34 @@ sdist.exclude = [
5252
"third_party/taskflow/examples",
5353
"third_party/taskflow/sandbox",
5454
"third_party/taskflow/unittests",
55-
"third_party/nanobind/doc",
56-
"third_party/nanobind/examples",
57-
"third_party/nanobind/scripts",
58-
"third_party/nanobind/tests",
5955
]
6056

57+
[tool.ruff]
58+
target-version = "py310"
59+
line-length = 120
60+
61+
[tool.ruff.lint]
62+
# TODO Add D, PTH, RET, disabled for now as they collides with intial choices
63+
select = ["E", "W", "YTT", "NPY", "PYI", "Q", "F", "B", "I", "SIM", "RUF"]
64+
# TODO: for now we ignore "Line too long error (E501)"
65+
# because our comments are too longs
66+
# code formatting will take care of the line length in code anyway
67+
ignore = [
68+
"E501",
69+
# Ignore docstring in public package and module
70+
"D100",
71+
"D104",
72+
# Blank line before class
73+
"D203",
74+
# multiline summary second line
75+
"D213",
76+
# yoda conditions
77+
"SIM300",
78+
]
79+
80+
[tool.ruff.lint.isort]
81+
known-first-party = ["pgeof"]
82+
6183
[tool.tox]
6284
legacy_tox_ini = """
6385
[tox]

tests/bench_jakteristics.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111

1212
@pytest.fixture
1313
def random_point_cloud():
14-
return np.random.rand(1000000, 3) * 100
14+
rng = np.random.default_rng()
15+
return rng.random(0, 100, size=((1000000, 3)))
1516

1617

1718
@pytest.mark.benchmark(group="feature-computation-jak", disable_gc=True, warmup=True)

tests/bench_knn.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77

88
@pytest.fixture
99
def random_point_cloud():
10-
return np.random.rand(100000, 3).astype("float32")
10+
rng = np.random.default_rng()
11+
return rng.random(0, 100, size=((1000000, 3))).astype("float32")
1112

1213

1314
@pytest.mark.benchmark(group="knn", disable_gc=True, warmup=True)

tests/helpers.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
def random_nn(num_points, k):
66
# Generate a random synthetic point cloud
7-
xyz = np.random.rand(num_points, 3)
7+
rng = np.random.default_rng()
8+
xyz = rng.random(size=(num_points, 3))
89

910
# Converting k-nearest neighbors to CSR format
1011
kneigh = KDTree(xyz).query(xyz, k=k, workers=-1)
@@ -20,4 +21,4 @@ def random_nn(num_points, k):
2021
xyz = np.ascontiguousarray(xyz)
2122
nn_ptr = np.ascontiguousarray(nn_ptr)
2223
nn = np.ascontiguousarray(nn)
23-
return xyz, nn, nn_ptr
24+
return xyz, nn, nn_ptr

tests/test_pgeof.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77

88
def test_knn():
99
knn = 10
10-
xyz = np.random.rand(1000, 3)
10+
rng = np.random.default_rng()
11+
xyz = rng.random(size=(1000, 3))
1112
xyz = xyz.astype("float32")
1213
tree = KDTree(xyz)
1314
_, k_legacy = tree.query(xyz, k=knn, workers=-1)
@@ -18,7 +19,8 @@ def test_knn():
1819
def test_radius_search():
1920
knn = 10
2021
radius = 0.2
21-
xyz = np.random.rand(1000, 3)
22+
rng = np.random.default_rng()
23+
xyz = rng.random(size=(1000, 3))
2224
xyz = xyz.astype("float32")
2325
tree = KDTree(xyz)
2426
_, k_legacy = tree.query(xyz, k=knn, distance_upper_bound=radius, workers=-1)
@@ -43,4 +45,4 @@ def test_pgeof_multiscale():
4345
simple = pgeof.compute_features(xyz, nn, nn_ptr, 50, False)
4446
multi_simple = pgeof.compute_features_multiscale(xyz, nn, nn_ptr, [20], False)
4547
np.testing.assert_allclose(multi[:, 0], multi_simple[:, 0], 1e-1, 1e-5)
46-
np.testing.assert_allclose(multi[:, 1], simple, 1e-1, 1e-5)
48+
np.testing.assert_allclose(multi[:, 1], simple, 1e-1, 1e-5)

0 commit comments

Comments
 (0)