AttributeError: 'module' object has no attribute 'block'

Hi Community,
I have faced a weird error I am trying to assemble my stiffness matrix through np.block which is work normally by running my script through my terminal but when I’m using that inside a fenics script this issue occurs.
Here I provide a simple examples of np.block:

import numpy as np
A = np.eye(2) * 2
B = np.eye(3) * 3
C = np.block([
[A, np.zeros((2, 3))],
[np.ones((3, 2)), B ]])
print(‘assembeled matrix =’, C)

I can get matrix C if I don’t use fenics and simply run the above lines.
But when I call fenics and then try to run this script this error occurs:

AttributeError: ‘module’ object has no attribute ‘block’

I appreciate any hint in this case.

I’m not able to reproduce this error, but is it possible that the environment you’re running FEniCS in has an older version of NumPy, which doesn’t have block?

1 Like

Hi David,

Thanks for your response, yes my NumPy version didn’t support block (It was 1.11) and I upgrade that to 1.16.4 which is working fine.