summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authora8212022-12-13 10:47:57 +0100
committera8212022-12-13 10:47:57 +0100
commitac0040d848a351d1400c177cd28dd3fcb1535667 (patch)
treeea5b79bf8363f1972a756360800cf75b8556db8e
parente4743c8ff6776fc18e6a6c0ffbb87a1b594e67b9 (diff)
downloadaur-ac0040d848a351d1400c177cd28dd3fcb1535667.tar.gz
Fix: np.matrix type not supported by sklearn
Some tests fail because the function `pairwise_distance` does not support the `numpy.matrix` type. The error suggest to call `numpy.asarray` first on the argument, so this patch does just that.
-rw-r--r--.SRCINFO4
-rw-r--r--.gitignore1
-rw-r--r--PKGBUILD13
-rw-r--r--asarray.patch22
4 files changed, 36 insertions, 4 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 8002d5c3da78..236c6b35dc2b 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,7 +1,7 @@
pkgbase = python-pynndescent
pkgdesc = Simple fast approximate nearest neighbor search
pkgver = 0.5.8
- pkgrel = 1
+ pkgrel = 2
url = https://github.com/lmcinnes/pynndescent
arch = any
license = BSD
@@ -12,6 +12,8 @@ pkgbase = python-pynndescent
depends = python-scikit-learn
depends = python-scipy
source = https://pypi.io/packages/source/p/pynndescent/pynndescent-0.5.8.tar.gz
+ source = asarray.patch
sha256sums = a7c552569bf604a101fd54bba1d27c12389e065945dee3a6777a518c63a46f2b
+ sha256sums = 240c9413befb3f7dd58a0f02a32e58a07c54abeef70cdaa222a3ec7bd8da7d63
pkgname = python-pynndescent
diff --git a/.gitignore b/.gitignore
index 4785aa5f48e2..69004319df09 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,4 @@
!/.SRCINFO
!/PKGBUILD
!/.gitignore
+!/*.patch
diff --git a/PKGBUILD b/PKGBUILD
index 10e5f65f7f32..83f65584feae 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,7 +1,7 @@
# Maintainer: a821
pkgname=python-pynndescent
pkgver=0.5.8
-pkgrel=1
+pkgrel=2
pkgdesc="Simple fast approximate nearest neighbor search"
arch=('any')
url="https://github.com/lmcinnes/pynndescent"
@@ -9,8 +9,15 @@ license=('BSD')
depends=('python-joblib' 'python-numba' 'python-scikit-learn' 'python-scipy')
makedepends=('python-setuptools')
checkdepends=('python-pytest')
-source=("https://pypi.io/packages/source/p/pynndescent/pynndescent-${pkgver}.tar.gz")
-sha256sums=('a7c552569bf604a101fd54bba1d27c12389e065945dee3a6777a518c63a46f2b')
+source=("https://pypi.io/packages/source/p/pynndescent/pynndescent-${pkgver}.tar.gz"
+ "asarray.patch")
+sha256sums=('a7c552569bf604a101fd54bba1d27c12389e065945dee3a6777a518c63a46f2b'
+ '240c9413befb3f7dd58a0f02a32e58a07c54abeef70cdaa222a3ec7bd8da7d63')
+
+prepare() {
+ cd "pynndescent-$pkgver"
+ patch -p1 < ../asarray.patch
+}
check() {
cd "pynndescent-$pkgver"
diff --git a/asarray.patch b/asarray.patch
new file mode 100644
index 000000000000..9ba097b106f2
--- /dev/null
+++ b/asarray.patch
@@ -0,0 +1,22 @@
+diff --git a/pynndescent/tests/test_distances.py b/pynndescent/tests/test_distances.py
+index 101530b..9ad88b0 100644
+--- a/pynndescent/tests/test_distances.py
++++ b/pynndescent/tests/test_distances.py
+@@ -109,7 +109,7 @@ def test_binary_check(binary_data, metric):
+ def test_sparse_spatial_check(sparse_spatial_data, metric, decimal=6):
+ if metric in spdist.sparse_named_distances:
+ dist_matrix = pairwise_distances(
+- sparse_spatial_data.todense().astype(np.float32), metric=metric
++ np.asarray(sparse_spatial_data.todense().astype(np.float32)), metric=metric
+ )
+ if metric in ("braycurtis", "dice", "sokalsneath", "yule"):
+ dist_matrix[np.where(~np.isfinite(dist_matrix))] = 0.0
+@@ -174,7 +174,7 @@ def test_sparse_spatial_check(sparse_spatial_data, metric, decimal=6):
+ )
+ def test_sparse_binary_check(sparse_binary_data, metric):
+ if metric in spdist.sparse_named_distances:
+- dist_matrix = pairwise_distances(sparse_binary_data.todense(), metric=metric)
++ dist_matrix = pairwise_distances(np.asarray(sparse_binary_data.todense()), metric=metric)
+ if metric in ("jaccard", "dice", "sokalsneath"):
+ dist_matrix[np.where(~np.isfinite(dist_matrix))] = 0.0
+ if metric in ("kulsinski", "russellrao"):