about summary refs log tree commit diff
path: root/pkgs/development/python-modules/shap/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/python-modules/shap/default.nix')
-rw-r--r--pkgs/development/python-modules/shap/default.nix143
1 files changed, 75 insertions, 68 deletions
diff --git a/pkgs/development/python-modules/shap/default.nix b/pkgs/development/python-modules/shap/default.nix
index 2bc1a8f5c2eca..7c21be0e36898 100644
--- a/pkgs/development/python-modules/shap/default.nix
+++ b/pkgs/development/python-modules/shap/default.nix
@@ -1,37 +1,38 @@
-{ lib
-, buildPythonPackage
-, fetchFromGitHub
-, pytestCheckHook
-, pythonOlder
-, writeText
-, catboost
-, cloudpickle
-, ipython
-, lightgbm
-, lime
-, matplotlib
-, nose
-, numba
-, numpy
-, oldest-supported-numpy
-, opencv4
-, pandas
-, pyspark
-, pytest-mpl
-, scikit-learn
-, scipy
-, sentencepiece
-, setuptools
-, setuptools-scm
-, slicer
-, tqdm
-, transformers
-, xgboost
+{
+  lib,
+  buildPythonPackage,
+  fetchFromGitHub,
+  pytestCheckHook,
+  pythonOlder,
+  writeText,
+  catboost,
+  cloudpickle,
+  ipython,
+  lightgbm,
+  lime,
+  matplotlib,
+  nose,
+  numba,
+  numpy,
+  oldest-supported-numpy,
+  opencv4,
+  pandas,
+  pyspark,
+  pytest-mpl,
+  scikit-learn,
+  scipy,
+  sentencepiece,
+  setuptools,
+  setuptools-scm,
+  slicer,
+  tqdm,
+  transformers,
+  xgboost,
 }:
 
 buildPythonPackage rec {
   pname = "shap";
-  version = "0.45.0";
+  version = "0.45.1";
   pyproject = true;
 
   disabled = pythonOlder "3.8";
@@ -40,7 +41,7 @@ buildPythonPackage rec {
     owner = "slundberg";
     repo = "shap";
     rev = "refs/tags/v${version}";
-    hash = "sha256-x8845saPoLsWu3Z8Thkhqo3HeLmfAZANj3KE0ftVqZc=";
+    hash = "sha256-REMAubT9WRe0exfhO4UCLt3FFQHq4HApHnI6i2F/V1o=";
   };
 
   nativeBuildInputs = [
@@ -61,43 +62,48 @@ buildPythonPackage rec {
   ];
 
   passthru.optional-dependencies = {
-    plots = [ matplotlib ipython ];
+    plots = [
+      matplotlib
+      ipython
+    ];
     others = [ lime ];
   };
 
-  preCheck = let
-    # This pytest hook mocks and catches attempts at accessing the network
-    # tests that try to access the network will raise, get caught, be marked as skipped and tagged as xfailed.
-    conftestSkipNetworkErrors = writeText "conftest.py" ''
-      from _pytest.runner import pytest_runtest_makereport as orig_pytest_runtest_makereport
-      import urllib, requests, transformers
-
-      class NetworkAccessDeniedError(RuntimeError): pass
-      def deny_network_access(*a, **kw):
-        raise NetworkAccessDeniedError
-
-      requests.head = deny_network_access
-      requests.get  = deny_network_access
-      urllib.request.urlopen = deny_network_access
-      urllib.request.Request = deny_network_access
-      transformers.AutoTokenizer.from_pretrained = deny_network_access
-
-      def pytest_runtest_makereport(item, call):
-        tr = orig_pytest_runtest_makereport(item, call)
-        if call.excinfo is not None and call.excinfo.type is NetworkAccessDeniedError:
-            tr.outcome = 'skipped'
-            tr.wasxfail = "reason: Requires network access."
-        return tr
+  preCheck =
+    let
+      # This pytest hook mocks and catches attempts at accessing the network
+      # tests that try to access the network will raise, get caught, be marked as skipped and tagged as xfailed.
+      conftestSkipNetworkErrors = writeText "conftest.py" ''
+        from _pytest.runner import pytest_runtest_makereport as orig_pytest_runtest_makereport
+        import urllib, requests, transformers
+
+        class NetworkAccessDeniedError(RuntimeError): pass
+        def deny_network_access(*a, **kw):
+          raise NetworkAccessDeniedError
+
+        requests.head = deny_network_access
+        requests.get  = deny_network_access
+        urllib.request.urlopen = deny_network_access
+        urllib.request.Request = deny_network_access
+        transformers.AutoTokenizer.from_pretrained = deny_network_access
+
+        def pytest_runtest_makereport(item, call):
+          tr = orig_pytest_runtest_makereport(item, call)
+          if call.excinfo is not None and call.excinfo.type is NetworkAccessDeniedError:
+              tr.outcome = 'skipped'
+              tr.wasxfail = "reason: Requires network access."
+          return tr
+      '';
+    in
+    ''
+      export HOME=$TMPDIR
+      # when importing the local copy the extension is not found
+      rm -r shap
+
+      # Add pytest hook skipping tests that access network.
+      # These tests are marked as "Expected fail" (xfail)
+      cat ${conftestSkipNetworkErrors} >> tests/conftest.py
     '';
-  in ''
-    export HOME=$TMPDIR
-    # when importing the local copy the extension is not found
-    rm -r shap
-
-    # Add pytest hook skipping tests that access network.
-    # These tests are marked as "Expected fail" (xfail)
-    cat ${conftestSkipNetworkErrors} >> tests/conftest.py
-  '';
 
   nativeCheckInputs = [
     ipython
@@ -134,15 +140,16 @@ buildPythonPackage rec {
     "test_simple_bar_with_cohorts_dict"
   ];
 
-  pythonImportsCheck = [
-    "shap"
-  ];
+  pythonImportsCheck = [ "shap" ];
 
   meta = with lib; {
     description = "A unified approach to explain the output of any machine learning model";
     homepage = "https://github.com/slundberg/shap";
     changelog = "https://github.com/slundberg/shap/releases/tag/v${version}";
     license = licenses.mit;
-    maintainers = with maintainers; [ evax natsukium ];
+    maintainers = with maintainers; [
+      evax
+      natsukium
+    ];
   };
 }