Open JonathanWenger opened 4 years ago
Suggested test:
def test_broadcasting(self):
"""Test broadcasting rules for linear operators and compare to np.array broadcasting."""
for alpha, A in list(itertools.product(self.scalars, self.ops)):
with self.subTest():
self.assertAllClose((alpha * A).todense(), alpha * A.todense())
self.assertAllClose((alpha + A).todense(), alpha + A.todense())
self.assertAllClose((A - alpha).todense(), A.todense() - alpha)
Linear operators should adhere by similar broadcasting rules as
RandomVariable
s andnp.ndarray
s. For exampleshould return a
_SumLinearOperator
.