Equality comparison mapper - #166
Conversation
343b4d0 to
859b387CompareUh oh!
There was an error while loading. Please reload this page.
74e42b4 to
bd1c612Comparekaushikcfd
commented
Oct 13, 2021
This is ready. The time taken by the |
inducer
left a comment
There was a problem hiding this comment.
Thanks for working on this! A few questions below, but generally this looks good.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| raise NotImplementedError | ||
| def map_placeholder(self, expr1: Placeholder, expr2: Any) -> bool: | ||
| return (isinstance(expr2, Placeholder) |
There was a problem hiding this comment.
isinstance isn't precise enough, since the object might compare equal to its subclass. I think the types need to match. (Yes, that was a bug in the original __eq__.)
There was a problem hiding this comment.
Went with expr1.__class__ is expr2.__class__
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
7847d63 to
4ee85e3Compare4ee85e3 to
2b47d9aCompare
inducer
left a comment
There was a problem hiding this comment.
Thanks! A few more superficial bits, then this is good to go.
| def handle_unsupported_array(self, expr1: Array, | ||
| expr2: Any) -> bool: | ||
| raise NotImplementedError |
There was a problem hiding this comment.
I think it'd be good to have an intelligible messages here.
There was a problem hiding this comment.
Added the type name. Thanks!
| raise NotImplementedError | ||
| def map_foreign(self, expr1: Any, expr2: Any) -> bool: | ||
| raise NotImplementedError |
There was a problem hiding this comment.
I think it'd be good to have an intelligible messages here.
There was a problem hiding this comment.
Added the type name. Thanks!
| from pytato.loopy import LoopyCall | ||
| __doc__ = """ | ||
| .. currentmodule:: pytato.equality |
There was a problem hiding this comment.
| .. currentmodule:: pytato.equality |
(not needed)
| if TYPE_CHECKING: | ||
| from pytato.loopy import LoopyCall | ||
| __doc__ = """ |
There was a problem hiding this comment.
Should this be hooked into the external docs somewhere?
| # }}} | ||
| def is_structurally_equivalent(expr1: ArrayOrNames, expr2: Any) -> bool: |
There was a problem hiding this comment.
- Not loving the name.
equivalentsuggests something more restrictive than equal. - Why not just call
EqualityComparisonMapper()(expr1, expr2)in__eq__?
| # {{{ EqualityComparisonMapper | ||
| class EqualityComparisonMapper: |
There was a problem hiding this comment.
| classEqualityComparisonMapper: | |
| classEqualityComparer: |
?
| .. note:: | ||
| Complexity: :math:`O(N)`, where :math:`N` is the number of nodes in | ||
| *expr1*. |
There was a problem hiding this comment.
This could get moved to the EqualityComparer docstring.
| # {{{ EqualityComparisonMapper | ||
| class EqualityComparisonMapper: | ||
| def __init__(self) -> None: |
There was a problem hiding this comment.
Add a docstring justifying why this object exists (to host caches for equality comparison, and that comparison might be exponential without it).
Co-authored-by: Andreas Kloeckner <inform@tiker.net>
2b47d9a to
1d31563Compareinducer
commented
Oct 19, 2021
Thanks! |
Closes#163