aboutsummaryrefslogtreecommitdiff
path: root/gnu/packages
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/packages')
-rw-r--r--gnu/packages/maths.scm41
-rw-r--r--gnu/packages/patches/python-accupy-fix-use-of-perfplot.patch48
-rw-r--r--gnu/packages/patches/python-accupy-use-matplotx.patch113
3 files changed, 202 insertions, 0 deletions
diff --git a/gnu/packages/maths.scm b/gnu/packages/maths.scm
index 386fb30cd9..2769c4f6ec 100644
--- a/gnu/packages/maths.scm
+++ b/gnu/packages/maths.scm
@@ -3650,6 +3650,47 @@ Cassowary solver with typical use cases gaining a 40x improvement. Memory
savings are consistently > 5x.")
(license license:bsd-3)))
+(define-public python-accupy
+ (package
+ (name "python-accupy")
+ (version "0.3.6")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/diego-hayashi/accupy")
+ (commit version)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "0sxkwpp2xy2jgakhdxr4nh1cspqv8l89kz6s832h05pbpyc0n767"))
+ (patches (search-patches "python-accupy-use-matplotx.patch"
+ "python-accupy-fix-use-of-perfplot.patch"))))
+ (build-system pyproject-build-system)
+ (arguments
+ (list
+ #:phases
+ #~(modify-phases %standard-phases
+ (add-after 'unpack 'set-eigen-include-dir
+ (lambda _
+ (substitute* "setup.py"
+ (("include_dirs=\\[\"\\/usr\\/include\\/eigen3\\/\"\\]," _)
+ (string-append "include_dirs=[\""
+ #$(file-append (this-package-input "eigen")
+ "/include/eigen3/")
+ "\"],"))))))))
+ (propagated-inputs (list eigen python-mpmath python-pyfma))
+ (native-inputs (list pybind11
+ python-matplotx
+ python-perfplot
+ python-pytest))
+ (home-page "https://github.com/diego-hayashi/accupy")
+ (synopsis "Accurate calculation of sums and dot products")
+ (description
+ "@code{accupy} is a Python library for accurately computing sums
+and (dot) products. It implements Kahan summation, Shewchuck's
+algorithm and summation in K-fold precision.")
+ (license license:gpl3+)))
+
(define-public slepc
(package
(name "slepc")
diff --git a/gnu/packages/patches/python-accupy-fix-use-of-perfplot.patch b/gnu/packages/patches/python-accupy-fix-use-of-perfplot.patch
new file mode 100644
index 0000000000..5b874e0056
--- /dev/null
+++ b/gnu/packages/patches/python-accupy-fix-use-of-perfplot.patch
@@ -0,0 +1,48 @@
+From 567558a4eb9b73ab30f9e469b36091eccf445f80 Mon Sep 17 00:00:00 2001
+From: Felix Gruber <felgru@posteo.net>
+Date: Sun, 23 Apr 2023 16:48:59 +0200
+Subject: [PATCH] Fix use of perfplot.
+
+data tuples are unpacked by perfplot before it calls the kernel
+functions.
+---
+ tests/test_dot.py | 16 ++++++++--------
+ 1 file changed, 8 insertions(+), 8 deletions(-)
+
+diff --git a/tests/test_dot.py b/tests/test_dot.py
+index a8160fe..51307ad 100644
+--- a/tests/test_dot.py
++++ b/tests/test_dot.py
+@@ -76,10 +76,10 @@ def test_speed_comparison1(n_range=None):
+ perfplot.plot(
+ setup=lambda n: (np.random.rand(n, 100), np.random.rand(100, n)),
+ kernels=[
+- lambda xy: np.dot(*xy),
+- lambda xy: accupy.kdot(*xy, K=2),
+- lambda xy: accupy.kdot(*xy, K=3),
+- lambda xy: accupy.fdot(*xy),
++ lambda x, y: np.dot(x, y),
++ lambda x, y: accupy.kdot(x, y, K=2),
++ lambda x, y: accupy.kdot(x, y, K=3),
++ lambda x, y: accupy.fdot(x, y),
+ ],
+ labels=["np.dot", "accupy.kdot[2]", "accupy.kdot[3]", "accupy.fdot"],
+ n_range=n_range,
+@@ -96,10 +96,10 @@ def test_speed_comparison2(n_range=None):
+ perfplot.plot(
+ setup=lambda n: (np.random.rand(100, n), np.random.rand(n, 100)),
+ kernels=[
+- lambda xy: np.dot(*xy),
+- lambda xy: accupy.kdot(*xy, K=2),
+- lambda xy: accupy.kdot(*xy, K=3),
+- lambda xy: accupy.fdot(*xy),
++ lambda x, y: np.dot(x, y),
++ lambda x, y: accupy.kdot(x, y, K=2),
++ lambda x, y: accupy.kdot(x, y, K=3),
++ lambda x, y: accupy.fdot(x, y),
+ ],
+ labels=["np.dot", "accupy.kdot[2]", "accupy.kdot[3]", "accupy.fdot"],
+ n_range=n_range,
+--
+2.39.2
+
diff --git a/gnu/packages/patches/python-accupy-use-matplotx.patch b/gnu/packages/patches/python-accupy-use-matplotx.patch
new file mode 100644
index 0000000000..f3dd17da22
--- /dev/null
+++ b/gnu/packages/patches/python-accupy-use-matplotx.patch
@@ -0,0 +1,113 @@
+From 1da1ed24cfba8a051b6c2f452a67ebfee77ca040 Mon Sep 17 00:00:00 2001
+From: Felix Gruber <felgru@posteo.net>
+Date: Sun, 23 Apr 2023 15:42:19 +0200
+Subject: [PATCH] Use dufte style from matplotx.
+
+The stand-alone dufte package has been deprecated in favor of the dufte
+style that has been integrated into matplotx.
+---
+ tests/test_dot.py | 10 +++++-----
+ tests/test_sums.py | 12 ++++++------
+ tox.ini | 2 +-
+ 3 files changed, 12 insertions(+), 12 deletions(-)
+
+diff --git a/tests/test_dot.py b/tests/test_dot.py
+index 0a40a0c..a8160fe 100644
+--- a/tests/test_dot.py
++++ b/tests/test_dot.py
+@@ -1,5 +1,5 @@
+-import dufte
+ import matplotlib.pyplot as plt
++import matplotx
+ import numpy as np
+ import perfplot
+ import pytest
+@@ -33,7 +33,7 @@ def test_fdot(cond):
+
+
+ def test_accuracy_comparison_illcond(target_cond=None):
+- plt.style.use(dufte.style)
++ plt.style.use(matplotx.styles.dufte)
+
+ if target_cond is None:
+ target_cond = [10 ** k for k in range(2)]
+@@ -61,13 +61,13 @@ def test_accuracy_comparison_illcond(target_cond=None):
+ for label, d in zip(labels, data.T):
+ plt.loglog(condition_numbers, d, label=label)
+
+- dufte.legend()
++ matplotx.line_labels()
+ plt.xlabel("condition number")
+- dufte.ylabel("relative error")
++ matplotx.ylabel_top("relative error")
+
+
+ def test_speed_comparison1(n_range=None):
+- plt.style.use(dufte.style)
++ plt.style.use(matplotx.styles.dufte)
+
+ if n_range is None:
+ n_range = [2 ** k for k in range(2)]
+diff --git a/tests/test_sums.py b/tests/test_sums.py
+index 1c0f6b0..8cd9ddb 100644
+--- a/tests/test_sums.py
++++ b/tests/test_sums.py
+@@ -1,5 +1,5 @@
+-import dufte
+ import matplotlib.pyplot as plt
++import matplotx
+ import numpy as np
+ import perfplot
+ import pytest
+@@ -32,7 +32,7 @@ def test_fsum(cond):
+
+
+ def test_accuracy_comparison_illcond(target_conds=None):
+- plt.style.use(dufte.style)
++ plt.style.use(matplotx.styles.dufte)
+
+ if target_conds is None:
+ target_conds = [10 ** k for k in range(1, 2)]
+@@ -71,14 +71,14 @@ def test_accuracy_comparison_illcond(target_conds=None):
+ for label, color, d in zip(labels, colors, data.T):
+ plt.loglog(condition_numbers, d, label=label, color=color)
+
+- dufte.legend()
++ matplotx.line_labels()
+ plt.xlabel("condition number")
+- dufte.ylabel("relative error")
++ matplotx.ylabel_top("relative error")
+ # plt.gca().set_aspect(1.3)
+
+
+ def test_speed_comparison1(n_range=None):
+- plt.style.use(dufte.style)
++ plt.style.use(matplotx.styles.dufte)
+
+ if n_range is None:
+ n_range = [2 ** k for k in range(2)]
+@@ -109,7 +109,7 @@ def test_speed_comparison1(n_range=None):
+
+
+ def test_speed_comparison2(n_range=None):
+- plt.style.use(dufte.style)
++ plt.style.use(matplotx.styles.dufte)
+
+ if n_range is None:
+ n_range = [2 ** k for k in range(2)]
+diff --git a/tox.ini b/tox.ini
+index 79a53ec..524b3bc 100644
+--- a/tox.ini
++++ b/tox.ini
+@@ -4,7 +4,7 @@ isolated_build = True
+
+ [testenv]
+ deps =
+- dufte
++ matplotx
+ perfplot
+ pytest
+ pytest-cov
+--
+2.39.2
+