Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add __hash__ function
  • Loading branch information
sebastien-rosset committed Apr 3, 2020
commit 645162c289c5d4655c198e2dc2e63c5f11f4de2a
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
"""Returns the string representation of the model"""
return pprint.pformat(self.to_dict())

def __hash__(self):
"""Returns the hash value of this object."""
return hash(frozenset(self._data_store.items()))

def __eq__(self, other):
"""Returns true if both objects are equal"""
if not isinstance(other, self.__class__):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
"""Returns the string representation of the model"""
return str(self.value)

def __hash__(self):
"""Returns the hash value of this object."""
return hash(self._data_store['value'])

def __eq__(self, other):
"""Returns true if both objects are equal"""
if not isinstance(other, self.__class__):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ def to_str(self):
"""Returns the string representation of the model"""
return str(self.value)

def __hash__(self):
"""Returns the hash value of this object."""
return hash(self._data_store['value'])

def __eq__(self, other):
"""Returns true if both objects are equal"""
if not isinstance(other, self.__class__):
Expand Down Expand Up @@ -204,6 +208,10 @@ def to_str(self):
"""Returns the string representation of the model"""
return pprint.pformat(self.to_dict())

def __hash__(self):
"""Returns the hash value of this object."""
return hash(frozenset(self._data_store.items()))

def __eq__(self, other):
"""Returns true if both objects are equal"""
if not isinstance(other, self.__class__):
Expand Down Expand Up @@ -307,6 +315,10 @@ def to_str(self):
"""Returns the string representation of the model"""
return pprint.pformat(self.to_dict())

def __hash__(self):
"""Returns the hash value of this object."""
return hash(frozenset(self._data_store.items()))

def __eq__(self, other):
"""Returns true if both objects are equal"""
if not isinstance(other, self.__class__):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ def to_str(self):
"""Returns the string representation of the model"""
return str(self.value)

def __hash__(self):
"""Returns the hash value of this object."""
return hash(self._data_store['value'])

def __eq__(self, other):
"""Returns true if both objects are equal"""
if not isinstance(other, self.__class__):
Expand Down Expand Up @@ -204,6 +208,10 @@ def to_str(self):
"""Returns the string representation of the model"""
return pprint.pformat(self.to_dict())

def __hash__(self):
"""Returns the hash value of this object."""
return hash(frozenset(self._data_store.items()))

def __eq__(self, other):
"""Returns true if both objects are equal"""
if not isinstance(other, self.__class__):
Expand Down Expand Up @@ -307,6 +315,10 @@ def to_str(self):
"""Returns the string representation of the model"""
return pprint.pformat(self.to_dict())

def __hash__(self):
"""Returns the hash value of this object."""
return hash(frozenset(self._data_store.items()))

def __eq__(self, other):
"""Returns true if both objects are equal"""
if not isinstance(other, self.__class__):
Expand Down