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 [
67 # AssertionError: assert (<xarray.DataArray 'yield' ()> Size: 1B\narray(False) & <xarray.DataArray 'yield' ()> Size: 1B\narray(False))
68 # https://github.com/bambinos/bambi/issues/888
69 "test_beta_regression"
70
71 # Tests require network access
72 "test_alias_equal_to_name"
73 "test_average_by"
74 "test_ax"
75 "test_basic"
76 "test_censored_response"
77 "test_custom_prior"
78 "test_data_is_copied"
79 "test_distributional_model"
80 "test_elasticity"
81 "test_extra_namespace"
82 "test_fig_kwargs"
83 "test_gamma_with_splines"
84 "test_group_effects"
85 "test_hdi_prob"
86 "test_legend"
87 "test_model_with_group_specific_effects"
88 "test_model_with_intercept"
89 "test_model_without_intercept"
90 "test_non_distributional_model"
91 "test_normal_with_splines"
92 "test_predict_new_groups_fail"
93 "test_predict_new_groups"
94 "test_predict_offset"
95 "test_set_alias_warnings"
96 "test_subplot_kwargs"
97 "test_transforms"
98 "test_use_hdi"
99 "test_with_group_and_panel"
100 "test_with_groups"
101 "test_with_user_values"
102 ]
103 ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [
104 # Python crash (in matplotlib)
105 # Fatal Python error: Aborted
106 "test_categorical_response"
107 "test_multiple_hsgp_and_by"
108 "test_multiple_outputs_with_alias"
109 "test_plot_priors"
110 "test_term_transformations"
111 ];
112
113 disabledTestPaths = [
114 # bayeux-ml is not available
115 "tests/test_alternative_samplers.py"
116 # Tests require network access
117 "tests/test_interpret.py"
118 "tests/test_interpret_messages.py"
119 ];
120
121 pythonImportsCheck = [ "bambi" ];
122
123 meta = {
124 description = "High-level Bayesian model-building interface";
125 homepage = "https://bambinos.github.io/bambi";
126 changelog = "https://github.com/bambinos/bambi/releases/tag/${src.tag}";
127 license = lib.licenses.mit;
128 maintainers = with lib.maintainers; [ bcdarwin ];
129 };
130}