Skip to content

Anomaly in overload of Ad_array.__rmul__ #819

Open
@vlipovac

Description

@vlipovac

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__

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is not working as expected.wontfixThis will not be worked on.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions