exoplanet-dev / exoplanet-dev/exoplanet-core

theano compatibility issue with numpy>1.20?

Open
#104 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
3
Forks
4
PR merge metrics
No merged PRs in 30d

Description

Attempting to import the pymc3 ops causes an error that appears to be related to theano compatibility issues with newer numpy versions. specifically,

```python
from exoplanet_core.pymc3 import ops
```

leads to the error:

```python
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
/var/folders/0y/0wb96bc544s1wvz3qvx484qh0000gn/T/ipykernel_62450/835514745.py in
----> 1 from exoplanet_core.pymc3 import ops

~/anaconda/envs/celmech/lib/python3.9/site-packages/exoplanet_core/pymc3/__init__.py in
20
21
---> 22 __set_compiler_flags()
23
24

~/anaconda/envs/celmech/lib/python3.9/site-packages/exoplanet_core/pymc3/__init__.py in __set_compiler_flags()
5
6 def __set_compiler_flags():
----> 7 import theano
8
9 def add_flag(current, new):

~/anaconda/envs/celmech/lib/python3.9/site-packages/Theano-1.0.5-py3.9.egg/theano/__init__.py in
122 from theano.printing import pprint, pp
123
--> 124 from theano.scan_module import (scan, map, reduce, foldl, foldr, clone,
125 scan_checkpoints)
126

~/anaconda/envs/celmech/lib/python3.9/site-packages/Theano-1.0.5-py3.9.egg/theano/scan_module/__init__.py in
39 __contact__ = "Razvan Pascanu "
40
---> 41 from theano.scan_module import scan_opt
42 from theano.scan_module.scan import scan
43 from theano.scan_module.scan_checkpoints import scan_checkpoints

~/anaconda/envs/celmech/lib/python3.9/site-packages/Theano-1.0.5-py3.9.egg/theano/scan_module/scan_opt.py in
58
59 import theano
---> 60 from theano import tensor, scalar
61 from theano.tensor import opt, get_scalar_constant_value, Alloc, AllocEmpty
62 from theano import gof

~/anaconda/envs/celmech/lib/python3.9/site-packages/Theano-1.0.5-py3.9.egg/theano/tensor/__init__.py in
6 import warnings
7
----> 8 from theano.tensor.basic import *
9 from theano.tensor.subtensor import *
10 from theano.tensor.type_other import *

~/anaconda/envs/celmech/lib/python3.9/site-packages/Theano-1.0.5-py3.9.egg/theano/tensor/basic.py in
18 from theano.gof.type import Generic
19
---> 20 from theano.scalar import int32 as int32_t
21 from theano.tensor import elemwise
22 from theano.tensor.var import (AsTensorError, TensorVariable,

~/anaconda/envs/celmech/lib/python3.9/site-packages/Theano-1.0.5-py3.9.egg/theano/scalar/__init__.py in
1 from __future__ import absolute_import, print_function, division
2
----> 3 from .basic import *
4
5 from .basic_scipy import *

~/anaconda/envs/celmech/lib/python3.9/site-packages/Theano-1.0.5-py3.9.egg/theano/scalar/basic.py in
2368 return s
2369
-> 2370 convert_to_bool = Cast(bool, name='convert_to_bool')
2371 convert_to_int8 = Cast(int8, name='convert_to_int8')
2372 convert_to_int16 = Cast(int16, name='convert_to_int16')

~/anaconda/envs/celmech/lib/python3.9/site-packages/Theano-1.0.5-py3.9.egg/theano/scalar/basic.py in __init__(self, o_type, name)
2321 super(Cast, self).__init__(specific_out(o_type), name=name)
2322 self.o_type = o_type
-> 2323 self.ctor = getattr(np, o_type.dtype)
2324
2325 def __str__(self):

~/anaconda/envs/celmech/lib/python3.9/site-packages/numpy/__init__.py in __getattr__(attr)
322
323 if attr in __former_attrs__:
--> 324 raise AttributeError(__former_attrs__[attr])
325
326 if attr == 'testing':

AttributeError: module 'numpy' has no attribute 'bool'.
`np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` 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
```

Contributor guide

Open the contributing guide

Research direction

Start from the exoplanet_core.pymc3 import entry point shown in the traceback and reproduce the failure with Theano 1.0.5 and a NumPy version above 1.20. Check the package's dependency configuration and compatibility tests, if present; done means importing exoplanet_core.pymc3.ops succeeds without the np.bool AttributeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.