Subject: [PATCH 2/2] gnu: Add python-bambi.

From: Vinicius Monego <[email-masked]>
Date: Tue, 5 Dec 2023 15:30:19 +0000

* gnu/packages/statistics.scm: Sort modules alphabetically.
(python-bambi): New variable.

Change-Id: I54931227310e3ad3b8d5c9272dcc641877b78bfb
---
 gnu/packages/statistics.scm | 77 +++++++++++++++++++++++++++++++++----
 1 file changed, 70 insertions(+), 7 deletions(-)

diff --git a/gnu/packages/statistics.scm b/gnu/packages/statistics.scm
index 30c6a9483e..c9a9672a35 100644
--- a/gnu/packages/statistics.scm
+++ b/gnu/packages/statistics.scm
@@ -35,25 +35,26 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (gnu packages statistics)
-  #:use-module (guix gexp)
   #:use-module ((guix licenses) #:prefix license:)
-  #:use-module (guix packages)
   #:use-module (guix download)
-  #:use-module (guix hg-download)
+  #:use-module (guix gexp)
   #:use-module (guix git-download)
+  #:use-module (guix hg-download)
+  #:use-module (guix packages)
   #:use-module (guix utils)
   #:use-module (guix build-system ant)
   #:use-module (guix build-system cmake)
   #:use-module (guix build-system emacs)
   #:use-module (guix build-system gnu)
-  #:use-module (guix build-system r)
   #:use-module (guix build-system pyproject)
   #:use-module (guix build-system python)
-  #:use-module (guix build-system trivial)
+  #:use-module (guix build-system r)
   #:use-module (guix build-system ruby)
+  #:use-module (guix build-system trivial)
   #:use-module (gnu packages)
   #:use-module (gnu packages algebra)
   #:use-module (gnu packages autotools)
+  #:use-module (gnu packages base)
   #:use-module (gnu packages bash)
   #:use-module (gnu packages bison)
   #:use-module (gnu packages boost)
@@ -66,9 +67,10 @@ (define-module (gnu packages statistics)
   #:use-module (gnu packages flex)
   #:use-module (gnu packages fontutils)
   #:use-module (gnu packages gcc)
-  #:use-module (gnu packages gtk)
   #:use-module (gnu packages gettext)
   #:use-module (gnu packages glib)
+  #:use-module (gnu packages graphviz)
+  #:use-module (gnu packages gtk)
   #:use-module (gnu packages haskell-xyz)
   #:use-module (gnu packages icu4c)
   #:use-module (gnu packages image)
@@ -100,7 +102,6 @@ (define-module (gnu packages statistics)
   #:use-module (gnu packages texinfo)
   #:use-module (gnu packages time)
   #:use-module (gnu packages tls)
-  #:use-module (gnu packages base)
   #:use-module (gnu packages uglifyjs)
   #:use-module (gnu packages version-control)
   #:use-module (gnu packages web)
@@ -2266,6 +2267,68 @@ (define-public python-formulae
 for mixed-effects models.")
     (license license:expat)))
 
+(define-public python-bambi
+  (package
+    (name "python-bambi")
+    (version "0.13.0")
+    (source
+     (origin
+       (method git-fetch) ;PyPI is missing files required by tests
+       (uri (git-reference
+             (url "https://github.com/bambinos/bambi")
+             (commit version)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "1hkkw65nbxg15rzp9rc8zxxwsg454hfa5mq853752hp6bp4r7szp"))))
+    (build-system pyproject-build-system)
+    (arguments
+     ;; The tests below use the network, and there's no configuration to
+     ;; skip the network tests.
+     (list
+      #:test-flags
+      #~(list "--ignore"
+              "tests/test_aliases.py"
+              "--ignore"
+              "tests/test_plots.py"
+              "-k"
+              (string-append
+               "not "
+               (string-join
+                (list
+                 "test_logistic_regression_categoric_alternative_samplers"
+                 "test_regression_alternative_samplers"
+                 "test_predict_new_groups"
+                 "test_predict_new_groups_fail"
+                 "test_censored_response"
+                 "test_data_is_copied"
+                 "test_extra_namespace"
+                 "test_predict_offset"
+                 "test_custom_prior"
+                 "test_normal_with_splines"
+                 "test_gamma_with_splines")
+                " and not ")))
+      #:phases #~(modify-phases %standard-phases
+                   (add-before 'check 'pre-check
+                     (lambda _
+                       ;; Some tests require write permission.
+                       (setenv "HOME" "/tmp"))))))
+    (propagated-inputs (list python-arviz python-formulae python-graphviz
+                             python-pandas python-pymc))
+    (native-inputs (list python-black
+                         python-ipython
+                         python-pylint
+                         python-pytest
+                         python-pytest-cov
+                         python-seaborn))
+    (home-page "https://bambinos.github.io/bambi/")
+    (synopsis "Bayesian Model Building Interface in Python")
+    (description
+     "Bambi is a high-level Bayesian model-building interface written in Python.
+It's built on top of the PyMC probabilistic programming framework, and is
+designed to make it extremely easy to fit mixed-effects models common in
+social sciences settings using a Bayesian approach.")
+    (license license:expat)))
+
 (define-public python-chaospy
   (package
     (name "python-chaospy")
-- 
2.39.2