Skip to content

Commit

Permalink
fix: support checking for binary equivalency
Browse files Browse the repository at this point in the history
  • Loading branch information
william-silversmith committed Jul 22, 2024
1 parent e0cf298 commit 378bd47
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions crackle/array.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Optional
from typing import Optional, Union, Any

from .headers import CrackleHeader
from .codec import (
Expand Down Expand Up @@ -79,8 +79,13 @@ def renumber(self, start:int = 0) -> bytes:
def decompress(self, label:Optional[int] = None) -> bytes:
return decompress(self.binary, label)

def __eq__(self, other:int) -> bool:
return self.min() == other and self.max() == other
def __eq__(self, other:Union[int, Any]) -> bool:
if isinstance(other, int):
return self.min() == other and self.max() == other
elif isinstance(other, CrackleArray):
return self.binary == other.binary
else:
raise TypeError(f"Type {type(other)} is not supported.")

def __add__(self, other:int) -> bytes:
return CrackleArray(add_scalar(self.binary, other))
Expand Down

0 comments on commit 378bd47

Please sign in to comment.