inducer / arraycontext

Choose your favorite numpy-workalike!
6 stars 11 forks source link

Make sure array containers handle `__eq__` reasonably #48

Closed inducer closed 3 years ago

inducer commented 3 years ago

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

majosm commented 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()).

inducer commented 3 years ago

Good question. Post #52, you can request two behaviors: