Closed inducer closed 3 years ago
I'm still trying to wrap my head around array containers and the issue mentioned here, but: is there a way to customize how a given array container type behaves with respect to ==
? In some cases it makes sense to return an array containing elementwise equality results, but in other cases, especially with scalar-like array containers like DOFArray
, I'd be tempted to say that a == b
should return a single value (i.e., there should be an implicit all()
).
Good question. Post #52, you can request two behaviors:
eq_comparison == True
will do the numpy thing: you get a new container full of arrays/containers with truth values.
Then we just need an all
workalike, which conceivably actx.np.all
could be. (Though for testing purposes we probably also want something that asserts structural equality and doesn't broadcast.)eq_comparison == False
, which has __eq__
returning NotImplemented
, which results in no two containers ever comparing equal.
A risk I perceive is that the dataclass implements an
eq
which just goes, hey, let's equality-compare all members, then decides, incorrectly, that, yup, things are equal.I don't know that it's mishandling stuff (as in, I haven't observed unsafe behavior). I'm writing this issue as a reminder to check (and write a test).
x-ref: https://github.com/inducer/arraycontext/pull/46/files#r659211749