Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround for #5310: theano import error with recent NumPy #5316

Merged
merged 1 commit into from
Jan 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
+ The `pm.Distribution(testval=...)` kwarg was deprecated and will be replaced by `pm.Distribution(initval=...)`in `pymc >=4` (see [#5226](https://github.com/pymc-devs/pymc/pulls/5226)).
+ The `pm.sample(start=...)` kwarg was deprecated and will be replaced by `pm.sample(initvals=...)`in `pymc >=4` (see [#5226](https://github.com/pymc-devs/pymc/pulls/5226)).

### Bugfixes
+ A hotfix is applied on import to remain compatible with NumPy 1.22 (see [#5316](https://github.com/pymc-devs/pymc/pull/5316)).

## PyMC3 3.11.4 (20 August 2021)

### New Features
Expand Down
22 changes: 22 additions & 0 deletions pymc3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,30 @@
import logging
import multiprocessing as mp
import platform
import warnings

import numpy.distutils
import semver

# Workaround for Theano bug that tries to access blas_opt_info;
# must be done before importing theano.
# https://github.com/pymc-devs/pymc/issues/5310
# Copied from theano/link/c/cmodule.py: default_blas_ldflags()
if (
hasattr(numpy.distutils, "__config__")
and numpy.distutils.__config__
and not hasattr(numpy.distutils.__config__, "blas_opt_info")
):
import numpy.distutils.system_info # noqa

# We need to catch warnings as in some cases NumPy print
# stuff that we don't want the user to see.
with warnings.catch_warnings(record=True):
numpy.distutils.system_info.system_info.verbosity = 0
blas_info = numpy.distutils.system_info.get_info("blas_opt")

numpy.distutils.__config__.blas_opt_info = blas_info

import theano

_log = logging.getLogger("pymc3")
Expand Down