Showing posts with label numpy. Show all posts
Showing posts with label numpy. Show all posts

AttributeError: module 'numpy.distutils.__config__' has no attribute 'blas_opt_info'

Errors

AttributeError: module 'numpy.distutils.__config__' has no attribute 'blas_opt_info'


Based on the issue discussed in https://github.com/numpy/numpy/issues/21079, a workaround is to change the cmodule in theano by commenting out the first line below and changing it to the second line.

$ vim ~/anaconda3/envs/pymc_env/lib/python3.10/site-packages/theano/link/c/cmodule.py:2621

2621             #blas_info = numpy.distutils.__config__.blas_opt_info
2622             blas_info = numpy.__config__.blas_opt_info

TypeError: Cannot cast ufunc multiply output from dtype('float64') to dtype('int16') with casting rule 'same_kind'


import numpy

A = numpy.array([1, 2, 3, 4], dtype=numpy.int16)
B = numpy.array([0.5, 2.1, 3, 4], dtype=numpy.float64)

A *= B

Solution:

Replace A *= B with A = A * B or numpy.multiply(A, B, out=A, casting='unsafe')