abcpy
abcpy copied to clipboard
Incompatibility with latest version of `numpy` and `matplotlib`
After installing abcpy
manually (not via pip), I encountered issues when running the examples. Specifically, I had the latest versions of numpy
(1.25.2
) and matplotlib
(3.7.2
) installed.
Running the examples (mpirun -np 10 --bind-to core python backends/mpi/pmcabc_gaussian.py
), I obtain the following error messages:
[...]
INFO:abcpy.inferences:Calculating acceptances threshold
INFO:abcpy.inferences:Calculating weights
INFO:abcpy.inferences:Calculate weights
INFO:abcpy.inferences:Calculating covariance matrix
Traceback (most recent call last):
File "/home/testuser/abcpy/examples/backends/mpi/pmcabc_gaussian.py", line 118, in <module>
journal = infer_parameters(backend, logging_level=logging.INFO)
File "/home/testuser/abcpy/examples/backends/mpi/pmcabc_gaussian.py", line 73, in infer_parameters
journal = sampler.sample([height_obs], steps, eps_arr, n_sample, n_samples_per_param, epsilon_percentile)
File "/home/testuser/.pyenv/versions/3.9.1/lib/python3.9/site-packages/abcpy/inferences.py", line 933, in sample
new_cov_mats = self.kernel.calculate_cov(self.accepted_parameters_manager)
File "/home/testuser/.pyenv/versions/3.9.1/lib/python3.9/site-packages/abcpy/perturbationkernel.py", line 144, in calculate_cov
all_covs.append(kernel.calculate_cov(accepted_parameters_manager, kernel_index))
File "/home/testuser/.pyenv/versions/3.9.1/lib/python3.9/site-packages/abcpy/perturbationkernel.py", line 266, in calculate_cov
(np.float, np.float32, np.float64, np.int, np.int32, np.int64)):
File "/home/testuser/.pyenv/versions/3.9.1/lib/python3.9/site-packages/numpy/__init__.py", line 319, in __getattr__
raise AttributeError(__former_attrs__[attr])
AttributeError: module 'numpy' has no attribute 'float'.
`np.float` was a deprecated alias for the builtin `float`. To avoid this error in existing code, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
--------------------------------------------------------------------------
Primary job terminated normally, but 1 process returned
a non-zero exit code. Per user-direction, the job has been aborted.
--------------------------------------------------------------------------
and
[...]
[0.00317671]
[0.00472121]
[0.00478266]]
{'mu': 177.04224197656742, 'sigma': 14.735985720015503}
(array([[185.31015072, -1.10226865],
[ -1.10226865, 33.72395735]]), dict_keys(['mu', 'sigma']))
{'type_model': ['Normal'], 'type_dist_func': ['LogReg'], 'steps': 3, 'epsilon_init': array([0.75]), 'n_samples': 250, 'n_samples_per_param': 10, 'epsilon_percentile': 10, 'covFactor': 2, 'full_output': 0, 'epsilon_arr': [0.75, 0.7402597402597402, 0.7402597402597402]}
Traceback (most recent call last):
File "/home/testuser/abcpy/examples/backends/mpi/pmcabc_gaussian.py", line 119, in <module>
analyse_journal(journal)
File "/home/testuser/abcpy/examples/backends/mpi/pmcabc_gaussian.py", line 91, in analyse_journal
journal.plot_posterior_distr(path_to_save="posterior.png")
File "/home/testuser/.pyenv/versions/3.9.1/lib/python3.9/site-packages/abcpy/output.py", line 847, in plot_posterior_distr
fig, axes = scatterplot_matrix(datat, meanpost, parameters_to_show,
File "/home/testuser/.pyenv/versions/3.9.1/lib/python3.9/site-packages/abcpy/output.py", line 663, in scatterplot_matrix
if ax.is_first_col():
AttributeError: 'Axes' object has no attribute 'is_first_col'
--------------------------------------------------------------------------
Primary job terminated normally, but 1 process returned
a non-zero exit code. Per user-direction, the job has been aborted.
--------------------------------------------------------------------------
Downgrading the packages as
-
numpy
from1.25.2
to1.23.5
-
matplotlib
from3.7.2
to3.5.3
fixes the problems.
Are there any plans updating the repository to account for the API changes of these major dependencies?
Hi, thank you very much for flagging this. We'll work on this and update the code base!