1{
2 lib,
3 stdenv,
4 arviz,
5 blackjax,
6 buildPythonPackage,
7 fetchFromGitHub,
8 formulae,
9 graphviz,
10 numpyro,
11 pandas,
12 pymc,
13 pytestCheckHook,
14 pythonOlder,
15 setuptools-scm,
16}:
17
18buildPythonPackage rec {
19 pname = "bambi";
20 version = "0.14.0";
21 pyproject = true;
22
23 disabled = pythonOlder "3.10";
24
25 src = fetchFromGitHub {
26 owner = "bambinos";
27 repo = "bambi";
28 rev = "refs/tags/${version}";
29 hash = "sha256-kxrNNbZfC96/XHb1I7aUHYZdFJvGR80ZI8ell/0FQXc=";
30 };
31
32 build-system = [ setuptools-scm ];
33
34 dependencies = [
35 arviz
36 formulae
37 graphviz
38 pandas
39 pymc
40 ];
41
42 # bayeux-ml is not available in nixpkgs
43 # optional-dependencies = {
44 # jax = [ bayeux-ml ];
45 # };
46
47 nativeCheckInputs = [
48 blackjax
49 numpyro
50 pytestCheckHook
51 ];
52
53 preCheck = ''
54 export HOME=$(mktemp -d)
55 '';
56
57 disabledTests =
58 [
59 # Tests require network access
60 "test_alias_equal_to_name"
61 "test_average_by"
62 "test_ax"
63 "test_basic"
64 "test_censored_response"
65 "test_custom_prior"
66 "test_data_is_copied"
67 "test_distributional_model"
68 "test_elasticity"
69 "test_extra_namespace"
70 "test_fig_kwargs"
71 "test_gamma_with_splines"
72 "test_group_effects"
73 "test_hdi_prob"
74 "test_legend"
75 "test_model_with_group_specific_effects"
76 "test_model_with_intercept"
77 "test_model_without_intercept"
78 "test_non_distributional_model"
79 "test_normal_with_splines"
80 "test_predict_new_groups_fail"
81 "test_predict_new_groups"
82 "test_predict_offset"
83 "test_set_alias_warnings"
84 "test_subplot_kwargs"
85 "test_transforms"
86 "test_use_hdi"
87 "test_with_group_and_panel"
88 "test_with_groups"
89 "test_with_user_values"
90 ]
91 ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [
92 # Python crash (in matplotlib)
93 # Fatal Python error: Aborted
94 "test_categorical_response"
95 "test_multiple_hsgp_and_by"
96 "test_multiple_outputs_with_alias"
97 "test_plot_priors"
98 "test_term_transformations"
99 ];
100
101 disabledTestPaths = [
102 # bayeux-ml is not available
103 "tests/test_alternative_samplers.py"
104 # Tests require network access
105 "tests/test_interpret.py"
106 "tests/test_interpret_messages.py"
107 ];
108
109 pythonImportsCheck = [ "bambi" ];
110
111 meta = {
112 description = "High-level Bayesian model-building interface";
113 homepage = "https://bambinos.github.io/bambi";
114 changelog = "https://github.com/bambinos/bambi/releases/tag/${version}";
115 license = lib.licenses.mit;
116 maintainers = with lib.maintainers; [ bcdarwin ];
117 };
118}