File: test-load-pynndescent_bug_np.npz-from-relative-path.patch

package info (click to toggle)
python-pynndescent 0.5.13-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,116 kB
  • sloc: python: 7,536; makefile: 12; sh: 8
file content (37 lines) | stat: -rw-r--r-- 1,304 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
From: Benjamin Drung <benjamin.drung@canonical.com>
Date: Sat, 1 Jun 2024 00:12:56 +0200
Subject: test: load pynndescent_bug_np.npz from relative path

The test `test_bad_data` will fail to load the test data
`pynndescent_bug_np.npz` in case the current directory is not the
repositories root directory.

Load the `pynndescent_bug_np.npz` test data relative from the test file
to not rely on the current directory.

Forwarded: https://github.com/lmcinnes/pynndescent/pull/243
Signed-off-by: Benjamin Drung <benjamin.drung@canonical.com>
---
 pynndescent/tests/test_pynndescent_.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- python-pynndescent.orig/pynndescent/tests/test_pynndescent_.py
+++ python-pynndescent/pynndescent/tests/test_pynndescent_.py
@@ -1,6 +1,7 @@
 import os
 import io
 import re
+import pathlib
 import pytest
 from contextlib import redirect_stdout
 
@@ -748,7 +749,8 @@
     "NUMBA_DISABLE_JIT" in os.environ, reason="Too expensive for disabled Numba"
 )
 def test_bad_data():
+    test_data_dir = pathlib.Path(__file__).parent / "test_data"
     data = np.sqrt(
-        np.load("pynndescent/tests/test_data/pynndescent_bug_np.npz")["arr_0"]
+        np.load(test_data_dir / "pynndescent_bug_np.npz")["arr_0"]
     )
     index = NNDescent(data, metric="cosine")