Open
Description
Hei,
I have tried to wrap my mind around what is happening here, but I have absolutely no clue
import numpy as np
import porepy as pp
import scipy.sparse as sps
a = pp.ad.Ad_array(np.array([1]), sps.csr_matrix((1,10)))
b = np.array([0.9])
c = b * a
print(type(c)) # c is of type numpy.ndarray
print(type(c[0])) # but it is a numpy array containing Ad_arrays!
The reverse order
c = a * b
would yield the expected result.
Edit:
In debug mode, one can see that in the case
c = b * a
b
is unwrapped into the number 0.9 and passed to __rmul__
In the other case
c = a * b
b
keeps its type and is passed as a numpy array into __mul__