summaryrefslogtreecommitdiffstats
path: root/pkgs/development/python-modules/bambi/default.nix
blob: 77c26e40b298b84be35e36d018ff5a3865a1a924 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
{
  lib,
  stdenv,
  buildPythonPackage,
  fetchFromGitHub,

  # build-system
  setuptools,
  setuptools-scm,

  # dependencies
  arviz-plots,
  formulae,
  graphviz,
  matplotlib,
  pandas,
  pymc,
  pytensor,
  seaborn,
  sparse,

  # tests
  blackjax,
  numpyro,
  pytest-mock,
  pytestCheckHook,
  writableTmpDirAsHomeHook,
}:

buildPythonPackage (finalAttrs: {
  pname = "bambi";
  version = "0.21.0";
  pyproject = true;
  __structuredAttrs = true;

  src = fetchFromGitHub {
    owner = "bambinos";
    repo = "bambi";
    tag = finalAttrs.version;
    hash = "sha256-1+NtsjGjVJLVqKD84IqpOoS2btON3hpHM2YI/pqmEN8=";
  };

  build-system = [
    setuptools
    setuptools-scm
  ];

  pythonRelaxDeps = [
    "sparse"
  ];
  dependencies = [
    arviz-plots
    formulae
    graphviz
    matplotlib
    pandas
    pymc
    pytensor
    seaborn
    sparse
  ];

  optional-dependencies = {
    jax = [
      # not (yet) available in nixpkgs (https://github.com/NixOS/nixpkgs/pull/345438)
      # bayeux-ml
    ];
  };

  nativeCheckInputs = [
    # bayeux-ml
    blackjax
    numpyro
    pytest-mock
    pytestCheckHook
    writableTmpDirAsHomeHook
  ];

  disabledTests = [
    # Requires `nutpie`, which is not packaged in nixpkgs
    "test_nuts_parameter_forwarded_to_external_samplers"

    # ValueError: dtype attribute is not a valid dtype instance
    "test_vonmises_regression"

    # AssertionError: assert (<xarray.DataArray 'yield' ()> Size: 1B\narray(False) & <xarray.DataArray 'yield' ()> Size: 1B\narray(False))
    # https://github.com/bambinos/bambi/issues/888
    "test_beta_regression"

    # Failing since blackjax was updated to 1.4
    # ValueError: cannot select an axis to squeeze out which has size not equal to one,
    # got shape=(4, 2) and dimensions=(0,)
    "test_blackjax_method"
    "test_legacy_nuts_blackjax_warning"

    # Tests require network access
    "test_alias_equal_to_name"
    "test_average_by"
    "test_ax"
    "test_basic"
    "test_categorical_and_interactions"
    "test_censored_response"
    "test_custom_prior"
    "test_data_is_copied"
    "test_distributional_model"
    "test_elasticity"
    "test_exclusion"
    "test_extra_namespace"
    "test_fig_kwargs"
    "test_gamma_with_splines"
    "test_group_effects"
    "test_hdi_prob"
    "test_inplace_false"
    "test_legend"
    "test_model_with_group_specific_effects"
    "test_model_with_intercept"
    "test_model_without_intercept"
    "test_no_offsets_when_centered_parametrization"
    "test_non_distributional_model"
    "test_normal_with_splines"
    "test_offsets_match_sampled_offsets"
    "test_offsets_reconstructed_with_sigma_alias"
    "test_offsets_reconstructed_without_centering"
    "test_predict_new_groups"
    "test_predict_new_groups_fail"
    "test_predict_offset"
    "test_same_variable_conditional_and_group"
    "test_set_alias_warnings"
    "test_subplot_kwargs"
    "test_transforms"
    "test_use_hdi"
    "test_with_group_and_panel"
    "test_with_groups"
    "test_with_user_values"
  ]
  ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [
    # Python crash (in matplotlib)
    # Fatal Python error: Aborted
    "test_categorical_response"
    "test_multiple_hsgp_and_by"
    "test_multiple_outputs_with_alias"
    "test_plot_priors"
    "test_term_transformations"
  ];

  disabledTestPaths = [
    # Tests require network access
    "tests/test_interpret_plots.py"
  ];

  pythonImportsCheck = [ "bambi" ];

  meta = {
    description = "High-level Bayesian model-building interface";
    homepage = "https://bambinos.github.io/bambi";
    changelog = "https://github.com/bambinos/bambi/releases/tag/${finalAttrs.src.tag}";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ bcdarwin ];
  };
})