diff --git a/.flake8 b/.flake8
index 87596071..ecee70e9 100644
--- a/.flake8
+++ b/.flake8
@@ -13,6 +13,8 @@ extend-ignore =
E501
# Empty method in an abstract base class
B027
+ # Disable black would make changes warning
+ BLK100
per-file-ignores =
# Imported but unused
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 4f0293b8..4ba53110 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -7,8 +7,8 @@ on:
- main
pull_request:
schedule:
- # run Monday and Thursday at 03:18 UTC
- - cron: '18 15 * * MON,THU'
+ # run Monday at 03:18 UTC
+ - cron: '18 15 * * MON'
jobs:
@@ -16,14 +16,14 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
- python-version: ['3.11', '3.9']
+ python-version: ['3.12', '3.11', '3.10']
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: Prepare python ${{ matrix.python-version }}
- uses: actions/setup-python@v1
+ uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
@@ -54,14 +54,14 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
- python-version: ['3.11', '3.9']
+ python-version: ['3.12']
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: Prepare python ${{ matrix.python-version }}
- uses: actions/setup-python@v1
+ uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
@@ -100,7 +100,7 @@ jobs:
uses: actions/checkout@v2
- name: Prepare python ${{ matrix.python-version }}
- uses: actions/setup-python@v1
+ uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
@@ -127,14 +127,14 @@ jobs:
runs-on: macos-latest
strategy:
matrix:
- python-version: ['3.11', '3.9']
+ python-version: ['3.12']
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: Prepare python ${{ matrix.python-version }}
- uses: actions/setup-python@v1
+ uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
@@ -161,14 +161,14 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
- python-version: ['3.11']
+ python-version: ['3.12']
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: Prepare python ${{ matrix.python-version }}
- uses: actions/setup-python@v1
+ uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
@@ -189,14 +189,14 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
- python-version: ['3.11']
+ python-version: ['3.12']
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: Prepare python ${{ matrix.python-version }}
- uses: actions/setup-python@v1
+ uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
@@ -224,7 +224,7 @@ jobs:
uses: actions/checkout@v2
- name: Prepare python ${{ matrix.python-version }}
- uses: actions/setup-python@v1
+ uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
index 11792879..582dd2d5 100644
--- a/.github/workflows/deploy.yml
+++ b/.github/workflows/deploy.yml
@@ -3,21 +3,21 @@ name: Deploy
on:
release:
types: [created]
-
+
jobs:
deploy:
runs-on: ubuntu-latest
strategy:
matrix:
- python-version: [3.9]
+ python-version: [3.12]
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: Prepare python ${{ matrix.python-version }}
- uses: actions/setup-python@v1
+ uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 04f1ebb6..cf183130 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -7,6 +7,18 @@ Release Notes
0.12 Series
...........
+0.12.15 (2024-10-29)
+--------------------
+
+General:
+
+* Minor improvements in the documentation
+* Minor bug fixes in dependencies
+* Minor bug fixed in general
+* Dropping support of python 3.9
+* Adding support for python 3.12
+
+
0.12.14 (2023-11-10)
--------------------
@@ -24,7 +36,7 @@ General:
Fixes (#615):
-* Fix for wrong assets path in abc-server-dash
+* Fix for wrong assets path in abc-server-dash
General
diff --git a/doc/conf.py b/doc/conf.py
index 3eb71d28..95b590a9 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -155,7 +155,7 @@
# Add notebooks prolog to Google Colab and nbviewer
nbsphinx_prolog = r"""
-{% set docname = 'github/icb-dcm/pyabc/blob/main/doc/' + env.doc2path(env.docname, base=None) %}
+{% set docname = 'github/icb-dcm/pyabc/blob/main/doc/' + env.doc2path(env.docname, base=None) | string %}
.. raw:: html
diff --git a/pyabc/acceptor/__init__.py b/pyabc/acceptor/__init__.py
index a08ea609..361bd31b 100644
--- a/pyabc/acceptor/__init__.py
+++ b/pyabc/acceptor/__init__.py
@@ -5,7 +5,6 @@
Acceptors handle the acceptance step.
"""
-
from .acceptor import (
Acceptor,
AcceptorResult,
diff --git a/pyabc/model/model.py b/pyabc/model/model.py
index 9228ee57..8a41a52b 100644
--- a/pyabc/model/model.py
+++ b/pyabc/model/model.py
@@ -47,7 +47,7 @@ class Model:
.. note::
Most likely you do not want to use this class directly, but the
- :class:`SimpleModel` instead, or even just pass a plain function
+ :class:`FunctionModel` instead, or even just pass a plain function
as model.
Parameters
@@ -216,7 +216,7 @@ class FunctionModel(Model):
A model which is initialized with a function which generates the samples.
For most cases this class will be adequate.
Note that you can also pass a plain function to the ABCSMC class, which
- then gets automatically converted to a SimpleModel.
+ then gets automatically converted to a FunctionModel.
Parameters
----------
@@ -252,7 +252,7 @@ def to_model(maybe_model: Union[Callable, Model]) -> Model:
Parameters
----------
maybe_model:
- Constructs a SimpleModel instance if a function is passed.
+ Constructs a FunctionModel instance if a function is passed.
If a Model instance is passed, the Model instance itself is
returned.
diff --git a/pyabc/petab/__init__.py b/pyabc/petab/__init__.py
index ee4b4dcf..049d9b24 100644
--- a/pyabc/petab/__init__.py
+++ b/pyabc/petab/__init__.py
@@ -4,5 +4,16 @@
Problem definitions in the PEtab format (https://petab.rtfd.io).
"""
+import warnings
from .amici import AmiciPetabImporter
+
+try:
+ import petab
+except ImportError:
+ warnings.warn(
+ "PEtab import requires an installation of petab "
+ "(https://github.com/PEtab-dev/PEtab). "
+ "Install via `pip3 install petab`.",
+ stacklevel=1,
+ )
diff --git a/pyabc/petab/amici.py b/pyabc/petab/amici.py
index 97726acc..a393565e 100644
--- a/pyabc/petab/amici.py
+++ b/pyabc/petab/amici.py
@@ -14,8 +14,8 @@
logger = logging.getLogger("ABC.PEtab")
try:
- import petab
- import petab.C as C
+ import petab.v1 as petab
+ import petab.v1.C as C
except ImportError:
petab = C = None
logger.error(
@@ -82,8 +82,8 @@ def __call__(self, par: Union[Sequence, Mapping]) -> Mapping:
for key in self.prior_scales.keys():
par[key] = rescale(
val=par[key],
- origin_scale=self.prior_scales,
- target_scale=self.scaled_scales,
+ origin_scale=self.prior_scales[key],
+ target_scale=self.scaled_scales[key],
)
# simulate model
diff --git a/pyabc/petab/base.py b/pyabc/petab/base.py
index 37aecea0..c8373177 100644
--- a/pyabc/petab/base.py
+++ b/pyabc/petab/base.py
@@ -14,8 +14,8 @@
logger = logging.getLogger("ABC.PEtab")
try:
- import petab
- import petab.C as C
+ import petab.v1 as petab
+ import petab.v1.C as C
except ImportError:
petab = C = None
logger.error(
diff --git a/pyabc/transition/local_transition.py b/pyabc/transition/local_transition.py
index b7f08cf9..9f9f500e 100644
--- a/pyabc/transition/local_transition.py
+++ b/pyabc/transition/local_transition.py
@@ -136,7 +136,10 @@ def _cov_and_inv(self, n, indices):
while det <= 0:
cov += np.identity(cov.shape[0]) * self.EPS
det = la.det(cov)
- inv_cov = la.inv(cov)
+ try:
+ inv_cov = la.inv(cov)
+ except np.linalg.LinAlgError:
+ inv_cov = np.linalg.pinv(cov) # Use pseudo-inverse as a fallback
return cov, inv_cov, det
def _cov(self, indices, n):
diff --git a/pyabc/version.py b/pyabc/version.py
index 62cc35af..b995499b 100644
--- a/pyabc/version.py
+++ b/pyabc/version.py
@@ -1 +1 @@
-__version__ = '0.12.14'
+__version__ = '0.12.15'
diff --git a/pyabc/weighted_statistics/weighted_statistics.py b/pyabc/weighted_statistics/weighted_statistics.py
index d10ab578..959ed0f2 100644
--- a/pyabc/weighted_statistics/weighted_statistics.py
+++ b/pyabc/weighted_statistics/weighted_statistics.py
@@ -129,7 +129,10 @@ def resample(points, weights, n):
"""
weights = np.asarray(weights)
weights /= np.sum(weights)
- resampled = np.random.choice(points, size=n, p=weights)
+ indices = np.random.choice(
+ points.shape[0], size=n, p=weights
+ ) # sample index from multi-dimensional sample
+ resampled = points[indices]
return resampled
diff --git a/setup.cfg b/setup.cfg
index 93c59294..51c81cb4 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -33,9 +33,9 @@ classifiers =
License :: OSI Approved :: BSD License
Operating System :: OS Independent
Programming Language :: Python
+ Programming Language :: Python :: 3.12
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.10
- Programming Language :: Python :: 3.9
keywords =
likelihood-free
inference
@@ -51,7 +51,7 @@ requires =
[options]
install_requires =
- numpy >= 1.19.1
+ numpy >= 1.23.5
scipy >= 1.5.2
pandas >= 2.0.1
cloudpickle >= 1.5.0
@@ -60,11 +60,11 @@ install_requires =
redis >= 2.10.6
distributed >= 2022.10.2
matplotlib >= 3.3.0
- sqlalchemy >= 2.0.12
+ sqlalchemy
jabbar >= 0.0.10
gitpython >= 3.1.7
-python_requires = >=3.9
+python_requires = >=3.10
# not zip safe b/c of Flask templates
zip_safe = False
@@ -74,11 +74,11 @@ include_package_data = True
packages = find:
[options.extras_require]
-webserver_flask =
+webserver-flask =
flask-bootstrap >= 3.3.7.1
flask >= 1.1.2
bokeh >= 3.0.1
-webserver_dash =
+webserver-dash =
dash >= 2.11.1
dash-bootstrap-components >= 1.4.2
pyarrow =
@@ -111,9 +111,9 @@ autograd =
examples =
notebook >= 6.1.4
doc =
- sphinx >= 6.2.1
- nbsphinx >= 0.8.9
- nbconvert >= 6.5.0
+ sphinx >= 8.1.3
+ nbsphinx >= 0.9.5
+ nbconvert >= 7.16.4
sphinx-rtd-theme >= 1.2.0
sphinx-autodoc-typehints >= 1.18.3
ipython >= 8.4.0
diff --git a/test/migrate/create_test_db.py b/test/migrate/create_test_db.py
index c6296b09..14cd8b1e 100644
--- a/test/migrate/create_test_db.py
+++ b/test/migrate/create_test_db.py
@@ -31,7 +31,13 @@ def model(p):
distance = pyabc.PNormDistance(p=2)
-abc = pyabc.ABCSMC(model, prior, distance, population_size=10)
+abc = pyabc.ABCSMC(
+ model,
+ prior,
+ distance,
+ population_size=10,
+ sampler=pyabc.SingleCoreSampler(),
+)
db_file = os.path.join(tempfile.gettempdir(), 'pyabc_test_migrate.db')
abc.new("sqlite:///" + db_file, observation)
abc.run(minimum_epsilon=0.1, max_nr_populations=3)
diff --git a/test/petab/test_petab.py b/test/petab/test_petab.py
index ed67daef..05370196 100644
--- a/test/petab/test_petab.py
+++ b/test/petab/test_petab.py
@@ -8,8 +8,8 @@
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
-import petab
-import petab.C as C
+import petab.v1 as petab
+import petab.v1.C as C
import pytest
import scipy.stats
@@ -18,9 +18,7 @@
@pytest.fixture(
- params=itertools.product(
- [petab.C.LIN, petab.C.LOG, petab.C.LOG10], [*petab.C.PRIOR_TYPES, None]
- )
+ params=itertools.product([C.LIN, C.LOG, C.LOG10], [*C.PRIOR_TYPES, None])
)
def prior_specs(request):
"""A one-line parameter df for a given prior type."""
diff --git a/test/petab/test_petab_suite.py b/test/petab/test_petab_suite.py
index 2b072fce..85d29cb5 100644
--- a/test/petab/test_petab_suite.py
+++ b/test/petab/test_petab_suite.py
@@ -12,7 +12,7 @@
try:
import amici.petab_import
import amici.petab_objective
- import petab
+ import petab.v1 as petab
import pyabc.petab
except ImportError:
diff --git a/tox.ini b/tox.ini
index 1da516fe..a0961f02 100644
--- a/tox.ini
+++ b/tox.ini
@@ -101,10 +101,14 @@ description =
[testenv:migrate]
extras = test,migrate
-deps = pytest-console-scripts
+deps =
+ setuptools>=65.5.0
+ wheel
+ pytest-console-scripts
commands =
+ pip install setuptools>=65.5.0 wheel # to ensure distutils is there in python 3.12
# install an old pyabc version
- pip install pyabc==0.10.13 pandas==1.5.0 sqlalchemy==1.4.48
+ pip install pyabc==0.10.13 numpy==1.23.5 pandas==1.5.0 sqlalchemy==1.4.48
python test/migrate/create_test_db.py
# back to latest pyabc version
pip install --upgrade .