2e reviewed manuscript

This commit is contained in:
Luciano Ramalho
2021-11-12 11:33:12 -03:00
parent f5e3cb8ad3
commit 80f7f84274
32 changed files with 323 additions and 156 deletions

View File

@@ -79,8 +79,6 @@ Tests of hashing:
>>> v1 = Vector2d(3, 4)
>>> v2 = Vector2d(3.1, 4.2)
>>> hash(v1), hash(v2)
(7, 384307168202284039)
>>> len({v1, v2})
2
@@ -124,7 +122,7 @@ class Vector2d:
return tuple(self) == tuple(other)
def __hash__(self):
return hash(self.x) ^ hash(self.y)
return hash((self.x, self.y))
def __abs__(self):
return math.hypot(self.x, self.y)

View File

@@ -81,8 +81,6 @@ Tests of hashing:
>>> v1 = Vector2d(3, 4)
>>> v2 = Vector2d(3.1, 4.2)
>>> hash(v1), hash(v2)
(7, 384307168202284039)
>>> len({v1, v2})
2
@@ -131,7 +129,7 @@ class Vector2d:
# tag::VECTOR_V3_HASH[]
def __hash__(self):
return hash(self.x) ^ hash(self.y)
return hash((self.x, self.y))
# end::VECTOR_V3_HASH[]
def __abs__(self):

View File

@@ -78,8 +78,6 @@ Tests of hashing:
>>> v1 = Vector2d(3, 4)
>>> v2 = Vector2d(3.1, 4.2)
>>> hash(v1), hash(v2)
(7, 384307168202284039)
>>> len({v1, v2})
2
@@ -126,7 +124,7 @@ class Vector2d:
return tuple(self) == tuple(other)
def __hash__(self):
return hash(self.x) ^ hash(self.y)
return hash((self.x, self.y))
def __abs__(self):
return math.hypot(self.x, self.y)