1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 pythonAtLeast,
6 pythonOlder,
7 # build inputs
8 networkx,
9 numpy,
10 scipy,
11 scikit-learn,
12 pandas,
13 pyparsing,
14 torch,
15 statsmodels,
16 tqdm,
17 joblib,
18 opt-einsum,
19 # check inputs
20 pytestCheckHook,
21 pytest-cov,
22 coverage,
23 mock,
24 black,
25}:
26let
27 pname = "pgmpy";
28 version = "0.1.25";
29in
30# optional-dependencies = {
31# all = [ daft ];
32# };
33buildPythonPackage {
34 inherit pname version;
35 format = "setuptools";
36
37 disabled = pythonOlder "3.7";
38
39 src = fetchFromGitHub {
40 owner = "pgmpy";
41 repo = pname;
42 rev = "refs/tags/v${version}";
43 hash = "sha256-d2TNcJQ82XxTWdetLgtKXRpFulAEEzrr+cyRewoA6YI=";
44 };
45
46 # TODO: Remove this patch after updating to pgmpy 0.1.26.
47 # The PR https://github.com/pgmpy/pgmpy/pull/1745 will have been merged.
48 # It contains the fix below, among other things, which is why we do not use fetchpatch.
49 postPatch = lib.optionalString (pythonAtLeast "3.12") ''
50 substituteInPlace pgmpy/tests/test_estimators/test_MarginalEstimator.py \
51 --replace-fail 'self.assert_' 'self.assertTrue'
52 '';
53
54 propagatedBuildInputs = [
55 networkx
56 numpy
57 scipy
58 scikit-learn
59 pandas
60 pyparsing
61 torch
62 statsmodels
63 tqdm
64 joblib
65 opt-einsum
66 ];
67
68 disabledTests = [
69 "test_to_daft" # requires optional dependency daft
70 ];
71
72 nativeCheckInputs = [
73 pytestCheckHook
74 # xdoctest
75 pytest-cov
76 coverage
77 mock
78 black
79 ];
80
81 meta = with lib; {
82 description = "Python Library for learning (Structure and Parameter), inference (Probabilistic and Causal), and simulations in Bayesian Networks";
83 homepage = "https://github.com/pgmpy/pgmpy";
84 changelog = "https://github.com/pgmpy/pgmpy/releases/tag/v${version}";
85 license = licenses.mit;
86 maintainers = with maintainers; [ happysalada ];
87 };
88}