Skip to content

Commit 57c8d16

Browse files
authored
Merge pull request #639 from ICB-DCM/develop
Minor bug fixes, new release
2 parents a322de3 + b0a1347 commit 57c8d16

File tree

18 files changed

+88
-50
lines changed

18 files changed

+88
-50
lines changed

.flake8

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ extend-ignore =
1313
E501
1414
# Empty method in an abstract base class
1515
B027
16+
# Disable black would make changes warning
17+
BLK100
1618

1719
per-file-ignores =
1820
# Imported but unused

.github/workflows/ci.yml

+14-14
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,23 @@ on:
77
- main
88
pull_request:
99
schedule:
10-
# run Monday and Thursday at 03:18 UTC
11-
- cron: '18 15 * * MON,THU'
10+
# run Monday at 03:18 UTC
11+
- cron: '18 15 * * MON'
1212

1313
jobs:
1414

1515
base:
1616
runs-on: ubuntu-latest
1717
strategy:
1818
matrix:
19-
python-version: ['3.11', '3.9']
19+
python-version: ['3.12', '3.11', '3.10']
2020

2121
steps:
2222
- name: Check out repository
2323
uses: actions/checkout@v2
2424

2525
- name: Prepare python ${{ matrix.python-version }}
26-
uses: actions/setup-python@v1
26+
uses: actions/setup-python@v4
2727
with:
2828
python-version: ${{ matrix.python-version }}
2929

@@ -54,14 +54,14 @@ jobs:
5454
runs-on: ubuntu-latest
5555
strategy:
5656
matrix:
57-
python-version: ['3.11', '3.9']
57+
python-version: ['3.12']
5858

5959
steps:
6060
- name: Check out repository
6161
uses: actions/checkout@v2
6262

6363
- name: Prepare python ${{ matrix.python-version }}
64-
uses: actions/setup-python@v1
64+
uses: actions/setup-python@v4
6565
with:
6666
python-version: ${{ matrix.python-version }}
6767

@@ -100,7 +100,7 @@ jobs:
100100
uses: actions/checkout@v2
101101

102102
- name: Prepare python ${{ matrix.python-version }}
103-
uses: actions/setup-python@v1
103+
uses: actions/setup-python@v4
104104
with:
105105
python-version: ${{ matrix.python-version }}
106106

@@ -127,14 +127,14 @@ jobs:
127127
runs-on: macos-latest
128128
strategy:
129129
matrix:
130-
python-version: ['3.11', '3.9']
130+
python-version: ['3.12']
131131

132132
steps:
133133
- name: Check out repository
134134
uses: actions/checkout@v2
135135

136136
- name: Prepare python ${{ matrix.python-version }}
137-
uses: actions/setup-python@v1
137+
uses: actions/setup-python@v4
138138
with:
139139
python-version: ${{ matrix.python-version }}
140140

@@ -161,14 +161,14 @@ jobs:
161161
runs-on: ubuntu-latest
162162
strategy:
163163
matrix:
164-
python-version: ['3.11']
164+
python-version: ['3.12']
165165

166166
steps:
167167
- name: Check out repository
168168
uses: actions/checkout@v2
169169

170170
- name: Prepare python ${{ matrix.python-version }}
171-
uses: actions/setup-python@v1
171+
uses: actions/setup-python@v4
172172
with:
173173
python-version: ${{ matrix.python-version }}
174174

@@ -189,14 +189,14 @@ jobs:
189189
runs-on: ubuntu-latest
190190
strategy:
191191
matrix:
192-
python-version: ['3.11']
192+
python-version: ['3.12']
193193

194194
steps:
195195
- name: Check out repository
196196
uses: actions/checkout@v2
197197

198198
- name: Prepare python ${{ matrix.python-version }}
199-
uses: actions/setup-python@v1
199+
uses: actions/setup-python@v4
200200
with:
201201
python-version: ${{ matrix.python-version }}
202202

@@ -224,7 +224,7 @@ jobs:
224224
uses: actions/checkout@v2
225225

226226
- name: Prepare python ${{ matrix.python-version }}
227-
uses: actions/setup-python@v1
227+
uses: actions/setup-python@v4
228228
with:
229229
python-version: ${{ matrix.python-version }}
230230

.github/workflows/deploy.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@ name: Deploy
33
on:
44
release:
55
types: [created]
6-
6+
77

88
jobs:
99
deploy:
1010
runs-on: ubuntu-latest
1111
strategy:
1212
matrix:
13-
python-version: [3.9]
13+
python-version: [3.12]
1414

1515
steps:
1616
- name: Check out repository
1717
uses: actions/checkout@v2
1818

1919
- name: Prepare python ${{ matrix.python-version }}
20-
uses: actions/setup-python@v1
20+
uses: actions/setup-python@v4
2121
with:
2222
python-version: ${{ matrix.python-version }}
2323

CHANGELOG.rst

+13-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@ Release Notes
77
0.12 Series
88
...........
99

10+
0.12.15 (2024-10-29)
11+
--------------------
12+
13+
General:
14+
15+
* Minor improvements in the documentation
16+
* Minor bug fixes in dependencies
17+
* Minor bug fixed in general
18+
* Dropping support of python 3.9
19+
* Adding support for python 3.12
20+
21+
1022
0.12.14 (2023-11-10)
1123
--------------------
1224

@@ -24,7 +36,7 @@ General:
2436

2537
Fixes (#615):
2638

27-
* Fix for wrong assets path in abc-server-dash
39+
* Fix for wrong assets path in abc-server-dash
2840

2941
General
3042

doc/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@
155155

156156
# Add notebooks prolog to Google Colab and nbviewer
157157
nbsphinx_prolog = r"""
158-
{% set docname = 'github/icb-dcm/pyabc/blob/main/doc/' + env.doc2path(env.docname, base=None) %}
158+
{% set docname = 'github/icb-dcm/pyabc/blob/main/doc/' + env.doc2path(env.docname, base=None) | string %}
159159
.. raw:: html
160160
161161
<div class="note">

pyabc/acceptor/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
Acceptors handle the acceptance step.
66
"""
77

8-
98
from .acceptor import (
109
Acceptor,
1110
AcceptorResult,

pyabc/model/model.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class Model:
4747
.. note::
4848
4949
Most likely you do not want to use this class directly, but the
50-
:class:`SimpleModel` instead, or even just pass a plain function
50+
:class:`FunctionModel` instead, or even just pass a plain function
5151
as model.
5252
5353
Parameters
@@ -216,7 +216,7 @@ class FunctionModel(Model):
216216
A model which is initialized with a function which generates the samples.
217217
For most cases this class will be adequate.
218218
Note that you can also pass a plain function to the ABCSMC class, which
219-
then gets automatically converted to a SimpleModel.
219+
then gets automatically converted to a FunctionModel.
220220
221221
Parameters
222222
----------
@@ -252,7 +252,7 @@ def to_model(maybe_model: Union[Callable, Model]) -> Model:
252252
Parameters
253253
----------
254254
maybe_model:
255-
Constructs a SimpleModel instance if a function is passed.
255+
Constructs a FunctionModel instance if a function is passed.
256256
If a Model instance is passed, the Model instance itself is
257257
returned.
258258

pyabc/petab/__init__.py

+11
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,16 @@
44
55
Problem definitions in the PEtab format (https://petab.rtfd.io).
66
"""
7+
import warnings
78

89
from .amici import AmiciPetabImporter
10+
11+
try:
12+
import petab
13+
except ImportError:
14+
warnings.warn(
15+
"PEtab import requires an installation of petab "
16+
"(https://github.com/PEtab-dev/PEtab). "
17+
"Install via `pip3 install petab`.",
18+
stacklevel=1,
19+
)

pyabc/petab/amici.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
logger = logging.getLogger("ABC.PEtab")
1515

1616
try:
17-
import petab
18-
import petab.C as C
17+
import petab.v1 as petab
18+
import petab.v1.C as C
1919
except ImportError:
2020
petab = C = None
2121
logger.error(
@@ -82,8 +82,8 @@ def __call__(self, par: Union[Sequence, Mapping]) -> Mapping:
8282
for key in self.prior_scales.keys():
8383
par[key] = rescale(
8484
val=par[key],
85-
origin_scale=self.prior_scales,
86-
target_scale=self.scaled_scales,
85+
origin_scale=self.prior_scales[key],
86+
target_scale=self.scaled_scales[key],
8787
)
8888

8989
# simulate model

pyabc/petab/base.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
logger = logging.getLogger("ABC.PEtab")
1515

1616
try:
17-
import petab
18-
import petab.C as C
17+
import petab.v1 as petab
18+
import petab.v1.C as C
1919
except ImportError:
2020
petab = C = None
2121
logger.error(

pyabc/transition/local_transition.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,10 @@ def _cov_and_inv(self, n, indices):
136136
while det <= 0:
137137
cov += np.identity(cov.shape[0]) * self.EPS
138138
det = la.det(cov)
139-
inv_cov = la.inv(cov)
139+
try:
140+
inv_cov = la.inv(cov)
141+
except np.linalg.LinAlgError:
142+
inv_cov = np.linalg.pinv(cov) # Use pseudo-inverse as a fallback
140143
return cov, inv_cov, det
141144

142145
def _cov(self, indices, n):

pyabc/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.12.14'
1+
__version__ = '0.12.15'

pyabc/weighted_statistics/weighted_statistics.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,10 @@ def resample(points, weights, n):
129129
"""
130130
weights = np.asarray(weights)
131131
weights /= np.sum(weights)
132-
resampled = np.random.choice(points, size=n, p=weights)
132+
indices = np.random.choice(
133+
points.shape[0], size=n, p=weights
134+
) # sample index from multi-dimensional sample
135+
resampled = points[indices]
133136
return resampled
134137

135138

setup.cfg

+9-9
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ classifiers =
3333
License :: OSI Approved :: BSD License
3434
Operating System :: OS Independent
3535
Programming Language :: Python
36+
Programming Language :: Python :: 3.12
3637
Programming Language :: Python :: 3.11
3738
Programming Language :: Python :: 3.10
38-
Programming Language :: Python :: 3.9
3939
keywords =
4040
likelihood-free
4141
inference
@@ -51,7 +51,7 @@ requires =
5151

5252
[options]
5353
install_requires =
54-
numpy >= 1.19.1
54+
numpy >= 1.23.5
5555
scipy >= 1.5.2
5656
pandas >= 2.0.1
5757
cloudpickle >= 1.5.0
@@ -60,11 +60,11 @@ install_requires =
6060
redis >= 2.10.6
6161
distributed >= 2022.10.2
6262
matplotlib >= 3.3.0
63-
sqlalchemy >= 2.0.12
63+
sqlalchemy
6464
jabbar >= 0.0.10
6565
gitpython >= 3.1.7
6666

67-
python_requires = >=3.9
67+
python_requires = >=3.10
6868

6969
# not zip safe b/c of Flask templates
7070
zip_safe = False
@@ -74,11 +74,11 @@ include_package_data = True
7474
packages = find:
7575

7676
[options.extras_require]
77-
webserver_flask =
77+
webserver-flask =
7878
flask-bootstrap >= 3.3.7.1
7979
flask >= 1.1.2
8080
bokeh >= 3.0.1
81-
webserver_dash =
81+
webserver-dash =
8282
dash >= 2.11.1
8383
dash-bootstrap-components >= 1.4.2
8484
pyarrow =
@@ -111,9 +111,9 @@ autograd =
111111
examples =
112112
notebook >= 6.1.4
113113
doc =
114-
sphinx >= 6.2.1
115-
nbsphinx >= 0.8.9
116-
nbconvert >= 6.5.0
114+
sphinx >= 8.1.3
115+
nbsphinx >= 0.9.5
116+
nbconvert >= 7.16.4
117117
sphinx-rtd-theme >= 1.2.0
118118
sphinx-autodoc-typehints >= 1.18.3
119119
ipython >= 8.4.0

test/migrate/create_test_db.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,13 @@ def model(p):
3131

3232
distance = pyabc.PNormDistance(p=2)
3333

34-
abc = pyabc.ABCSMC(model, prior, distance, population_size=10)
34+
abc = pyabc.ABCSMC(
35+
model,
36+
prior,
37+
distance,
38+
population_size=10,
39+
sampler=pyabc.SingleCoreSampler(),
40+
)
3541
db_file = os.path.join(tempfile.gettempdir(), 'pyabc_test_migrate.db')
3642
abc.new("sqlite:///" + db_file, observation)
3743
abc.run(minimum_epsilon=0.1, max_nr_populations=3)

test/petab/test_petab.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
import matplotlib.pyplot as plt
99
import numpy as np
1010
import pandas as pd
11-
import petab
12-
import petab.C as C
11+
import petab.v1 as petab
12+
import petab.v1.C as C
1313
import pytest
1414
import scipy.stats
1515

@@ -18,9 +18,7 @@
1818

1919

2020
@pytest.fixture(
21-
params=itertools.product(
22-
[petab.C.LIN, petab.C.LOG, petab.C.LOG10], [*petab.C.PRIOR_TYPES, None]
23-
)
21+
params=itertools.product([C.LIN, C.LOG, C.LOG10], [*C.PRIOR_TYPES, None])
2422
)
2523
def prior_specs(request):
2624
"""A one-line parameter df for a given prior type."""

0 commit comments

Comments
 (0)