1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2015, 2016, 2020, 2021 Ricardo Wurmus <rekado@elephly.net>
3 ;;; Copyright © 2015 Federico Beffa <beffa@fbengineering.ch>
4 ;;; Copyright © 2016 Ben Woodcroft <donttrustben@gmail.com>
5 ;;; Copyright © 2016 Hartmut Goebel <h.goebel@crazy-compilers.com>
6 ;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
7 ;;; Copyright © 2016, 2017, 2018, 2019, 2020 Marius Bakke <mbakke@fastmail.com>
8 ;;; Copyright © 2019 Tobias Geerinckx-Rice <me@tobias.gr>
9 ;;; Copyright © 2019 Maxim Cournoyer <maxim.cournoyer@gmail.com>
10 ;;; Copyright © 2019 Giacomo Leidi <goodoldpaul@autistici.org>
11 ;;; Copyright © 2020 Pierre Langlois <pierre.langlois@gmx.com>
12 ;;; Copyright © 2020, 2021 Vinicius Monego <monego@posteo.net>
13 ;;; Copyright © 2021 Greg Hogan <code@greghogan.com>
14 ;;; Copyright © 2021 Roel Janssen <roel@gnu.org>
15 ;;; Copyright © 2021 Paul Garlick <pgarlick@tourbillion-technology.com>
17 ;;; This file is part of GNU Guix.
19 ;;; GNU Guix is free software; you can redistribute it and/or modify it
20 ;;; under the terms of the GNU General Public License as published by
21 ;;; the Free Software Foundation; either version 3 of the License, or (at
22 ;;; your option) any later version.
24 ;;; GNU Guix is distributed in the hope that it will be useful, but
25 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
26 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 ;;; GNU General Public License for more details.
29 ;;; You should have received a copy of the GNU General Public License
30 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
32 (define-module (gnu packages python-science)
33 #:use-module ((guix licenses) #:prefix license:)
34 #:use-module (gnu packages)
35 #:use-module (gnu packages base)
36 #:use-module (gnu packages check)
37 #:use-module (gnu packages gcc)
38 #:use-module (gnu packages image-processing)
39 #:use-module (gnu packages maths)
40 #:use-module (gnu packages mpi)
41 #:use-module (gnu packages perl)
42 #:use-module (gnu packages pkg-config)
43 #:use-module (gnu packages python)
44 #:use-module (gnu packages python-build)
45 #:use-module (gnu packages python-check)
46 #:use-module (gnu packages python-web)
47 #:use-module (gnu packages python-xyz)
48 #:use-module (gnu packages simulation)
49 #:use-module (gnu packages sphinx)
50 #:use-module (gnu packages time)
51 #:use-module (gnu packages xdisorg)
52 #:use-module (gnu packages xml)
53 #:use-module (gnu packages xorg)
54 #:use-module (guix packages)
55 #:use-module (guix download)
56 #:use-module (guix git-download)
57 #:use-module (guix utils)
58 #:use-module (guix build-system python))
60 (define-public python-scipy
67 (uri (pypi-uri "scipy" version))
69 (base32 "0rh5b1rwdcvvagld8vpxnpaibszy1skpx39a0fwzd5gx5pwcjvfb"))))
70 (build-system python-build-system)
72 `(("python-numpy" ,python-numpy)
73 ("python-matplotlib" ,python-matplotlib)
74 ("python-pyparsing" ,python-pyparsing)))
76 `(("openblas" ,openblas)
77 ("pybind11" ,pybind11)))
79 `(("python-cython" ,python-cython)
80 ("python-pytest" ,python-pytest)
81 ("python-sphinx" ,python-sphinx)
82 ("python-numpydoc" ,python-numpydoc)
83 ("gfortran" ,gfortran)
86 (outputs '("out" "doc"))
89 (modify-phases %standard-phases
90 (add-before 'build 'change-home-dir
92 ;; Change from /homeless-shelter to /tmp for write permission.
93 (setenv "HOME" "/tmp")
95 (add-after 'unpack 'disable-broken-tests
97 (substitute* "scipy/sparse/linalg/dsolve/tests/test_linsolve.py"
98 (("^( +)def test_threads_parallel\\(self\\):" m indent)
100 "@pytest.mark.skip(reason=\"Disabled by Guix\")\n"
102 (substitute* "scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py"
103 (("^def test_parallel_threads\\(\\):" m)
104 (string-append "@pytest.mark.skip(reason=\"Disabled by Guix\")\n"
107 (add-before 'build 'configure-openblas
108 (lambda* (#:key inputs #:allow-other-keys)
109 (call-with-output-file "site.cfg"
114 library_dirs = ~a/lib
115 include_dirs = ~a/include
117 # backslash-n to make emacs happy
119 library_dirs = ~a/lib
120 atlas_libs = openblas
122 (assoc-ref inputs "openblas")
123 (assoc-ref inputs "openblas")
124 (assoc-ref inputs "openblas"))))
126 (add-after 'install 'install-doc
127 (lambda* (#:key inputs outputs #:allow-other-keys)
128 (let* ((data (string-append (assoc-ref outputs "doc") "/share"))
129 (doc (string-append data "/doc/" ,name "-" ,version))
130 (html (string-append doc "/html"))
131 (pyver ,(string-append "PYVER=" (version-major+minor
132 (package-version python))))
133 ;; By default it tries to run sphinx-build through the Python
134 ;; interpreter which won't work with our shell wrapper.
135 (sphinxbuild "SPHINXBUILD=LANG=C sphinx-build"))
136 ;; Make installed package available for building the
138 (add-installed-pythonpath inputs outputs)
139 (with-directory-excursion "doc"
140 ;; Fix generation of images for mathematical expressions.
141 (substitute* (find-files "source" "conf\\.py")
142 (("pngmath_use_preview = True")
143 "pngmath_use_preview = False"))
145 (invoke "make" "html" pyver sphinxbuild)
146 (with-directory-excursion "build/html"
147 (for-each (lambda (file)
148 (let* ((dir (dirname file))
149 (tgt-dir (string-append html "/" dir)))
150 (install-file file html)))
151 (find-files "." ".*")))))
153 ;; Tests can only be run after the library has been installed and not
154 ;; within the source directory.
156 (add-after 'install 'check
157 (lambda* (#:key inputs outputs #:allow-other-keys)
158 (add-installed-pythonpath inputs outputs)
159 (with-directory-excursion "/tmp"
160 (invoke "python" "-c"
161 "import scipy; scipy.test(verbose=2)")))))))
162 (home-page "https://www.scipy.org/")
163 (synopsis "The Scipy library provides efficient numerical routines")
164 (description "The SciPy library is one of the core packages that make up
165 the SciPy stack. It provides many user-friendly and efficient numerical
166 routines such as routines for numerical integration and optimization.")
167 (properties `((python2-variant . ,(delay python2-scipy))))
168 (license license:bsd-3)))
170 ;; Version 1.2.2 is the last version to support Python 2
171 (define-public python2-scipy
173 (inherit (package-with-python2
174 (strip-python2-variant python-scipy)))
179 (uri (pypi-uri "scipy" version))
182 "1cgvgin8fvckv96hjh3ikmwkra5rif51bdb75ifzf7xbil5iwcx4"))))))
184 (define-public python2-weave
186 (name "python2-weave")
191 (uri (pypi-uri "weave" version))
193 (base32 "0jnm3584mfichgwgrd1gk5i42ll9c08nkw9716n947n4338f6ghs"))))
194 (build-system python-build-system)
198 (modify-phases %standard-phases
201 (invoke "nosetests" "-v"
203 "test_(user|incorrect_ownership|char_fail|obj_fail)"))))))
205 `(("python-numpy" ,python2-numpy)))
207 `(("python-nose" ,python2-nose)))
208 (home-page "https://www.scipy.org/")
209 (synopsis "Tools for including C/C++ code within Python code")
210 (description "Weave is the stand-alone version of the obsolete Scipy
211 submodule @code{scipy.weave}. It is Python 2.x only, and is provided for
212 users that need new versions of Scipy but have existing code that still
213 depends on @code{scipy.weave}. For new code, users are recommended to use
215 (license license:bsd-3)))
217 (define-public python-scikit-fuzzy
219 (name "python-scikit-fuzzy")
224 (uri (pypi-uri "scikit-fuzzy" version))
226 (base32 "0bp1n771fj44kdp7a00bcvfwirvv2rc803b7g6yf3va7v0j29c8s"))))
227 (build-system python-build-system)
230 (modify-phases %standard-phases
233 (invoke "nosetests" "-s" "-v" "skfuzzy")
236 `(("python-nose" ,python-nose)))
238 `(("python-networkx" ,python-networkx)
239 ("python-numpy" ,python-numpy)
240 ("python-scipy" ,python-scipy)))
241 (home-page "https://github.com/scikit-fuzzy/scikit-fuzzy")
242 (synopsis "Fuzzy logic toolkit for SciPy")
244 "This package implements many useful tools for projects involving fuzzy
245 logic, also known as grey logic.")
246 (license license:bsd-3)))
248 (define-public python-scikit-image
250 (name "python-scikit-image")
255 (uri (pypi-uri "scikit-image" version))
257 (base32 "0wgisa03smhrphcjnhq7waa5vyyd32b67hblapjbqrqqj751idpv"))))
258 (build-system python-build-system)
261 (modify-phases %standard-phases
262 (add-before 'build 'change-home-dir
264 ;; Change from /homeless-shelter to /tmp for write permission.
265 (setenv "HOME" "/tmp")
272 ;; The following tests require online data.
273 (invoke "python" "-m" "pytest" "skimage" "--doctest-modules" "-k"
274 (string-append "not test_ndim"
275 " and not test_skin")))))))
276 ;; See requirements/ for the list of build and run time requirements.
277 ;; NOTE: scikit-image has an optional dependency on python-pooch, however
278 ;; propagating it would enable many more tests that require online data.
280 `(("python-cloudpickle" ,python-cloudpickle)
281 ("python-dask" ,python-dask)
282 ("python-imageio" ,python-imageio)
283 ("python-matplotlib" ,python-matplotlib)
284 ("python-networkx" ,python-networkx)
285 ("python-numpy" ,python-numpy)
286 ("python-pillow" ,python-pillow)
287 ("python-pywavelets" ,python-pywavelets)
288 ("python-scipy" ,python-scipy)
289 ("python-tifffile" ,python-tifffile)))
291 `(("python-codecov" ,python-codecov)
292 ("python-cython" ,python-cython)
293 ("python-flake8" ,python-flake8)
294 ("python-pytest" ,python-pytest)
295 ("python-pytest-cov" ,python-pytest-cov)
296 ("python-pytest-localserver" ,python-pytest-localserver)
297 ("python-wheel" ,python-wheel)))
298 (home-page "https://scikit-image.org/")
299 (synopsis "Image processing in Python")
301 "Scikit-image is a collection of algorithms for image processing.")
302 (license license:bsd-3)))
304 (define-public python-sgp4
311 (uri (pypi-uri "sgp4" version))
313 (base32 "0dncp9i5b6afkg7f8mj9j0qzsp008b8v73yc0qkmizhpns7mvwvx"))))
314 (build-system python-build-system)
316 `(("python-numpy" ,python-numpy)))
317 (home-page "https://github.com/brandon-rhodes/python-sgp4")
318 (synopsis "Track earth satellite TLE orbits using SGP4")
320 "This package provides a Python implementation of the most recent version
321 of the SGP4 satellite tracking algorithm.")
322 (license license:expat)))
324 (define-public python-pandas
326 (name "python-pandas")
331 (uri (pypi-uri "pandas" version))
333 (base32 "1a2gv3g6jr6vb5ca43fkwjl5xf86wpfz8y3zcy787adjl0hdkib9"))))
334 (build-system python-build-system)
336 `(#:modules ((guix build utils)
337 (guix build python-build-system)
340 #:phases (modify-phases %standard-phases
341 (add-after 'unpack 'patch-which
342 (lambda* (#:key inputs #:allow-other-keys)
343 (let ((which (assoc-ref inputs "which")))
344 (substitute* "pandas/io/clipboard/__init__.py"
346 (string-append "WHICH_CMD = \"" which "\"\n"))))
348 (add-before 'check 'prepare-x
351 (setenv "DISPLAY" ":0")
352 ;; xsel needs to write a log file.
353 (setenv "HOME" "/tmp")
357 (let ((build-directory
360 (car (scandir "build"
361 (cut string-prefix? "lib." <>))))))
362 ;; Disable the "strict data files" option which causes
363 ;; the build to error out if required data files are
364 ;; not available (as is the case with PyPI archives).
365 (substitute* "setup.cfg"
366 (("addopts = --strict-data-files") "addopts = "))
367 (with-directory-excursion build-directory
368 (invoke "pytest" "-vv" "pandas" "--skip-slow"
369 "--skip-network"))))))))
371 `(("python-jinja2" ,python-jinja2)
372 ("python-numpy" ,python-numpy)
373 ("python-openpyxl" ,python-openpyxl)
374 ("python-pytz" ,python-pytz)
375 ("python-dateutil" ,python-dateutil)
376 ("python-xlrd" ,python-xlrd)))
382 `(("python-cython" ,python-cython)
383 ("python-beautifulsoup4" ,python-beautifulsoup4)
384 ("python-lxml" ,python-lxml)
385 ("python-html5lib" ,python-html5lib)
386 ("python-nose" ,python-nose)
387 ("python-pytest" ,python-pytest)
388 ("python-pytest-mock" ,python-pytest-mock)
389 ;; Needed to test clipboard support.
390 ("xorg-server" ,xorg-server-for-tests)))
391 (home-page "https://pandas.pydata.org")
392 (synopsis "Data structures for data analysis, time series, and statistics")
394 "Pandas is a Python package providing fast, flexible, and expressive data
395 structures designed to make working with structured (tabular,
396 multidimensional, potentially heterogeneous) and time series data both easy
397 and intuitive. It aims to be the fundamental high-level building block for
398 doing practical, real world data analysis in Python.")
399 (properties `((python2-variant . ,(delay python2-pandas))))
400 (license license:bsd-3)))
402 (define-public python-pandas-0.25
404 (inherit python-pandas)
408 (uri (pypi-uri "pandas" version))
411 "191048m6kdc6yfvqs9w412lq60cfvigrsb57y0x116lwibgp9njj"))))
413 (substitute-keyword-arguments (package-arguments python-pandas)
415 `(modify-phases ,phases
416 (replace 'patch-which
417 (lambda* (#:key inputs #:allow-other-keys)
418 (let ((which (assoc-ref inputs "which")))
419 (substitute* "pandas/io/clipboard/__init__.py"
421 (string-append "CHECK_CMD = \"" which "\"\n"))))
423 (delete 'prepare-x)))))))
425 ;; Pandas 0.24.x are the last versions that support Python 2.
426 (define-public python2-pandas
427 (let ((pandas (package-with-python2
428 (strip-python2-variant python-pandas-0.25))))
434 (uri (pypi-uri "pandas" version))
437 "18imlm8xbhcbwy4wa957a1fkamrcb0z988z006jpfda3ki09z4ag"))
438 (modules '((guix build utils)))
441 ;; Adjust for renamed error message in Python 2.7.17. Taken
442 ;; from <https://github.com/pandas-dev/pandas/pull/29294>.
443 (substitute* "pandas/io/parsers.py"
444 (("if 'NULL byte' in msg:")
445 "if 'NULL byte' in msg or 'line contains NUL' in msg:"))
448 (define-public python-pyflow
450 (name "python-pyflow")
455 "https://github.com/Illumina/pyflow/releases/download/v"
456 version "/pyflow-" version ".tar.gz"))
459 "1bvfvviw58cndyn862qnv9nj3d9cd3a0dm4vc4sd9vwq8a6z1riv"))))
460 (build-system python-build-system)
462 `(#:tests? #f)) ; There is no test suite.
463 (home-page "https://illumina.github.io/pyflow/")
464 (synopsis "Tool to manage tasks in a task dependency graph")
465 (description "This package is a Python module to manage tasks in the
466 context of a task dependency graph. It has some similarities to make.")
467 (license license:bsd-2)))
469 (define-public python-bottleneck
471 (name "python-bottleneck")
476 (uri (pypi-uri "Bottleneck" version))
478 (base32 "0wz5320jx3n4q2nsvwvc7cpi66b46qbals9v53m955rmcq5ry5r0"))))
479 (build-system python-build-system)
482 (modify-phases %standard-phases
485 (invoke "python" "setup.py" "pytest"))))))
487 `(("python-hypothesis" ,python-hypothesis)
488 ("python-pytest" ,python-pytest)
489 ("python-pytest-runner" ,python-pytest-runner)))
491 `(("python-numpy" ,python-numpy)))
492 (home-page "https://github.com/pydata/bottleneck")
493 (synopsis "Fast NumPy array functions written in C")
495 "Bottleneck is a collection of fast, NaN-aware NumPy array functions
497 (license license:bsd-2)))
499 (define-public python-baycomp
501 (name "python-baycomp")
506 (uri (pypi-uri "baycomp" version))
508 (base32 "1c1354a7b3g8slychjgyjxqdm8z40z9kviyl9n4g9kfpdg0p4d64"))))
509 (build-system python-build-system)
511 `(("python-matplotlib" ,python-matplotlib)
512 ("python-numpy" ,python-numpy)
513 ("python-scipy" ,python-scipy)))
514 (home-page "https://github.com/janezd/baycomp")
515 (synopsis "Library for comparison of Bayesian classifiers")
517 "Baycomp is a library for Bayesian comparison of classifiers. Functions
518 in the library compare two classifiers on one or on multiple data sets. They
519 compute three probabilities: the probability that the first classifier has
520 higher scores than the second, the probability that differences are within the
521 region of practical equivalence (rope), or that the second classifier has
523 (license license:expat)))
525 (define-public python-xarray
527 (name "python-xarray")
531 (uri (pypi-uri "xarray" version))
534 "1yx8j66b7rn10m2l6gmn8yr9cn38pi5cj0x0wwpy4hdnhy6i7qv4"))))
535 (build-system python-build-system)
537 `(("python-setuptools-scm" ,python-setuptools-scm)
538 ("python-pytest" ,python-pytest)))
540 `(("python-numpy" ,python-numpy)
541 ("python-pandas" ,python-pandas)))
544 (modify-phases %standard-phases
547 (invoke "pytest"))))))
548 (home-page "https://github.com/pydata/xarray")
549 (synopsis "N-D labeled arrays and datasets")
550 (description "Xarray (formerly xray) makes working with labelled
551 multi-dimensional arrays simple, efficient, and fun!
553 Xarray introduces labels in the form of dimensions, coordinates and attributes
554 on top of raw NumPy-like arrays, which allows for a more intuitive, more
555 concise, and less error-prone developer experience. The package includes a
556 large and growing library of domain-agnostic functions for advanced analytics
557 and visualization with these data structures.")
558 (license license:asl2.0)))
560 (define-public python-msgpack-numpy
562 (name "python-msgpack-numpy")
563 (version "0.4.6.post0")
567 (uri (pypi-uri "msgpack-numpy" version))
570 "0syzy645mwcy7lfjwz6pc8f9p2vv1qk4limc8iina3l5nnf0rjyz"))))
571 (build-system python-build-system)
573 `(("python-msgpack" ,python-msgpack)
574 ("python-numpy" ,python-numpy)))
575 (home-page "https://github.com/lebedov/msgpack-numpy")
577 "Numpy data serialization using msgpack")
579 "This package provides encoding and decoding routines that enable the
580 serialization and deserialization of numerical and array data types provided
581 by numpy using the highly efficient @code{msgpack} format. Serialization of
582 Python's native complex data types is also supported.")
583 (license license:bsd-3)))
585 (define-public python-ruffus
587 (name "python-ruffus")
592 (uri (pypi-uri "ruffus" version))
595 "1ai673k1s94s8b6pyxai8mk17p6zvvyi87rl236fs6ls8mpdklvc"))))
596 (build-system python-build-system)
599 (modify-phases %standard-phases
601 (add-after 'install 'check
602 (lambda* (#:key tests? inputs outputs #:allow-other-keys)
604 (add-installed-pythonpath inputs outputs)
605 (with-directory-excursion "ruffus/test"
606 (invoke "bash" "run_all_unit_tests3.cmd"))))))))
608 `(("python-pytest" ,python-pytest)))
609 (home-page "http://www.ruffus.org.uk")
610 (synopsis "Light-weight computational pipeline management")
612 "Ruffus is designed to allow scientific and other analyses to be
613 automated with the minimum of fuss and the least effort.")
614 (license license:expat)))
616 (define-public python-statannot
618 (name "python-statannot")
623 (uri (pypi-uri "statannot" version))
626 "1f8c2sylzr7lpjbyqxsqlp9xi8rj3d8c9hfh98x4jbb83zxc4026"))))
627 (build-system python-build-system)
629 `(("python-numpy" ,python-numpy)
630 ("python-seaborn" ,python-seaborn)
631 ("python-matplotlib" ,python-matplotlib)
632 ("python-pandas" ,python-pandas)
633 ("python-scipy" ,python-scipy)))
635 "https://github.com/webermarcolivier/statannot")
636 (synopsis "Add annotations to existing plots generated by seaborn")
638 "This is a Python package to compute statistical test and add statistical
639 annotations on an existing boxplots and barplots generated by seaborn.")
640 (license license:expat)))
642 (define-public python-upsetplot
644 (name "python-upsetplot")
649 (uri (pypi-uri "UpSetPlot" version))
652 "0kwljcmsvrxm33y3ssham2bwv4a5m31mv96y9h18va0cv7s3mqn1"))))
653 (build-system python-build-system)
656 (modify-phases %standard-phases
657 (add-after 'unpack 'fix-versioning
659 (substitute* "setup.py"
660 (("pytest-cov<2.6") "pytest-cov"))))
662 (lambda* (#:key inputs outputs #:allow-other-keys)
663 (add-installed-pythonpath inputs outputs)
664 (invoke "pytest" "-v" "--doctest-modules"))))))
666 `(("python-matplotlib" ,python-matplotlib)
667 ("python-pandas" ,python-pandas)))
669 `(("python-pytest-runner" ,python-pytest-runner)
670 ("python-pytest-cov" ,python-pytest-cov)))
671 (home-page "https://upsetplot.readthedocs.io")
672 (synopsis "Draw UpSet plots with Pandas and Matplotlib")
674 "This is a Python implementation of UpSet plots by Lex et al.
675 UpSet plots are used to visualize set overlaps; like Venn diagrams but more
677 (license license:bsd-3)))
679 (define-public python-vedo
687 (url "https://github.com/marcomusy/vedo")
689 (file-name (git-file-name name version))
692 "18i3ajh5jzhpc86di15lwh4jv97jhm627ii877sa4yhv6abzjfpn"))))
693 (build-system python-build-system)
696 (modify-phases %standard-phases
697 (add-after 'build 'mpi-setup
700 (lambda* (#:key inputs outputs #:allow-other-keys)
701 (setenv "HOME" (getcwd))
702 (add-installed-pythonpath inputs outputs)
703 (with-directory-excursion "tests"
704 (for-each (lambda (dir)
705 (with-directory-excursion dir
706 (invoke "./run_all.sh")))
707 '("common" "dolfin")))
709 (inputs ; for the check phase
711 ("pkgconfig" ,python-pkgconfig)
712 ("matplotlib" ,python-matplotlib)))
713 (native-inputs ; for python-pkgconfig
714 `(("pkg-config" ,pkg-config)))
716 `(("numpy" ,python-numpy)
718 (home-page "https://github.com/marcomusy/vedo")
720 "Analysis and visualization of 3D objects and point clouds")
722 "@code{vedo} is a fast and lightweight python module for
723 scientific analysis and visualization. The package provides a wide
724 range of functionalities for working with three-dimensional meshes and
725 point clouds. It can also be used to generate high quality
726 two-dimensional renderings such as scatter plots and histograms.
727 @code{vedo} is based on @code{vtk} and @code{numpy}, with no other
729 ;; vedo is released under the Expat license. Included fonts are
730 ;; covered by the OFL license and textures by the CC0 license.
731 ;; The earth images are in the public domain.
732 (license (list license:expat
735 license:public-domain))))