Repository: ICB-DCM/pyABC

Issue:
Cloudpickle >=1.5.0 breaks on python<=3.7
TBD what changed in 1.5.0 https://github.com/cloudpipe/cloudpickle

Also, add a base test on legacy python versions as these are still quite popular.

Comments:

Patch:
diff --git a/.github/workflows/ci_push.yml b/.github/workflows/ci_push.yml
index 52bc7d5..635cb1d 100644
--- a/.github/workflows/ci_push.yml
+++ b/.github/workflows/ci_push.yml
@@ -8,7 +8,7 @@ jobs:
     runs-on: ubuntu-latest
     strategy:
       matrix:
-        python-version: [3.8]
+        python-version: [3.8, 3.7]
 
     steps:
     - name: Check out repository
@@ -47,7 +47,7 @@ jobs:
     runs-on: ubuntu-latest
     strategy:
       matrix:
-        python-version: [3.8]
+        python-version: [3.8, 3.7]
 
     steps:
     - name: Check out repository
@@ -85,7 +85,7 @@ jobs:
     runs-on: ubuntu-latest
     strategy:
       matrix:
-        python-version: [3.8]
+        python-version: [3.8, 3.7]
 
     steps:
     - name: Check out repository
@@ -123,7 +123,7 @@ jobs:
     runs-on: macos-latest
     strategy:
       matrix:
-        python-version: [3.8]
+        python-version: [3.8, 3.7]
 
     steps:
       - name: Check out repository
@@ -147,7 +147,7 @@ jobs:
           pip install -e .[test]
 
       - name: Run tests
-        timeout-minutes: 3
+        timeout-minutes: 4
         run: |
           python -m pytest --cov=pyabc --cov-report=xml test/base/test_macos.py
 
@@ -184,7 +184,7 @@ jobs:
         pip install -e .[quality]
 
     - name: Run flake8
-      timeout-minutes: 1
+      timeout-minutes: 2
       run: ./run_flake8.sh
 
     - name: Run pyroma
diff --git a/pyabc/sampler/mapping.py b/pyabc/sampler/mapping.py
index 6db46ad..92c49de 100644
--- a/pyabc/sampler/mapping.py
+++ b/pyabc/sampler/mapping.py
@@ -1,7 +1,7 @@
 import functools
 import random
 
-import dill as pickle
+import cloudpickle as pickle
 import numpy as np
 
 from .base import Sampler
diff --git a/setup.cfg b/setup.cfg
index 9b7e0e3..c14d398 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -53,7 +53,6 @@ install_requires =
     flask >= 1.1.2
     bokeh >= 2.1.1
     redis >= 2.10.6
-    dill >= 0.3.2
     gitpython >= 3.1.7
     scikit-learn >= 0.23.1
     matplotlib >= 3.3.0
@@ -77,7 +76,7 @@ packages = find:
 
 [options.extras_require]
 R =
-    rpy2 >= 3.2.0
+    rpy2 >= 3.3.6
     cffi >= 1.13.1
 petab =
     petab >= 0.1.8


Test patch:
diff --git a/test/base/test_transition.py b/test/base/test_transition.py
index 2aad858..c0632c7 100644
--- a/test/base/test_transition.py
+++ b/test/base/test_transition.py
@@ -265,16 +265,16 @@ def test_discrete_jump_transition():
     def freq(weight):
         return p_stay * weight + p_move * (1 - weight)
 
-    assert 0 < sum(res.a == 5) / n_sample <= p_move + 0.05
-    assert freq(0.45) < sum(res.a == 4) / n_sample < freq(0.55)
-    assert freq(0.15) < sum(res.a == 2.5) / n_sample < freq(0.25)
-    assert freq(0.25) < sum(res.a == 0.5) / n_sample < freq(0.35)
+    assert 0 < sum(res.a == 5) / n_sample <= p_move + 0.1
+    assert freq(0.4) < sum(res.a == 4) / n_sample < freq(0.6)
+    assert freq(0.1) < sum(res.a == 2.5) / n_sample < freq(0.3)
+    assert freq(0.2) < sum(res.a == 0.5) / n_sample < freq(0.4)
 
     # test density calculation
-    assert np.isclose(trans.pdf(pd.Series({'a': 5})), freq(0.))
-    assert np.isclose(trans.pdf(pd.Series({'a': 4})), freq(0.5))
-    assert np.isclose(trans.pdf(pd.Series({'a': 2.5})), freq(0.2))
-    assert np.isclose(trans.pdf(pd.Series({'a': 0.5})), freq(0.3))
+    assert abs(trans.pdf(pd.Series({'a': 5})) - freq(0.)) < 1e-3
+    assert abs(trans.pdf(pd.Series({'a': 4})) - freq(0.5)) < 1e-3
+    assert abs(trans.pdf(pd.Series({'a': 2.5})) - freq(0.2)) < 1e-3
+    assert abs(trans.pdf(pd.Series({'a': 0.5})) - freq(0.3)) < 1e-3
 
 
 def test_discrete_jump_transition_errors():