Skip to content

Commit 2e5ca23

Browse files
committed
implement Color.__eq__, fix Color.__mul__
this allows testing of color block sorting algorithms with CPython
1 parent c615ccf commit 2e5ca23

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/pybricks/parameters.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,12 @@ def __iter__(self):
119119
def __repr__(self):
120120
return "Color(h={}, s={}, v={})".format(self.h, self.s, self.v)
121121

122-
def __eq__(self, other: Color) -> bool: ...
122+
def __eq__(self, other: Color) -> bool:
123+
return self.h == other.h and self.s == other.s and self.v == other.v
123124

124125
def __mul__(self, scale: float) -> Color:
125126
v = max(0, min(self.v * scale, 100))
126-
return Color(self.h, self.s, int(v), self.name)
127+
return Color(self.h, self.s, int(v))
127128

128129
def __rmul__(self, scale: float) -> Color:
129130
return self.__mul__(scale)

0 commit comments

Comments
 (0)