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