Skip to content

Commit

Permalink
change __eq__ method
Browse files Browse the repository at this point in the history
  • Loading branch information
aerubanov committed Jan 24, 2022
1 parent 2f4c35b commit 184bc31
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions aesara/sparse/type.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,12 @@ def may_share_memory(a, b):
def make_variable(self, name=None):
return self.Variable(self, name=name)

def __eq__(self, other):
return (
super().__eq__(other)
and type(self) == type(other)
and other.format == self.format
)
# def __eq__(self, other):
# return (
# super().__eq__(other)
# and type(self) == type(other)
# and other.format == self.format
# )

def __hash__(self):
return super().__hash__() ^ hash(self.format)
Expand Down Expand Up @@ -215,15 +215,24 @@ def value_zeros(self, shape):

return matrix_constructor(shape, dtype=self.dtype)

def __eq__(self, other):
if type(self) != type(other):
return NotImplemented

return other.dtype == self.dtype and other.format == self.format

def is_super(self, otype):
if (
isinstance(otype, type(self))
and otype.dtype == self.dtype
and otype.ndim == self.ndim
and self.format == otype.format
):
# if (
# isinstance(otype, SparseType)
# and otype.dtype == self.dtype
# and otype.ndim == self.ndim
# and self.format == otype.format
# and otype.broadcastable == self.broadcastable
# ):
# return True
# return False
if self == otype:
return True

return False


Expand Down

0 comments on commit 184bc31

Please sign in to comment.