Skip to content

theano compatibility issue with numpy>1.20? #104

@shadden

Description

@shadden

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

from exoplanet_core.pymc3 import ops

leads to the error:

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

~/anaconda/envs/celmech/lib/python3.9/site-packages/exoplanet_core/pymc3/__init__.py in <module>
     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 <module>
    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 <module>
     39 __contact__ = "Razvan Pascanu <r.pascanu@gmail>"
     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 <module>
     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 <module>
      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 <module>
     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 <module>
      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 <module>
   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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions