diff --git a/numcodecs/delta.py b/numcodecs/delta.py index 09a5601e..f6307312 100644 --- a/numcodecs/delta.py +++ b/numcodecs/delta.py @@ -64,7 +64,10 @@ def encode(self, buf): # compute differences # using np.subtract for in-place operations - np.subtract(arr[1:], arr[0:-1], out=enc[1:]) + if arr.dtype == bool: + np.not_equal(arr[1:], arr[:-1], out=enc[1:]) + else: + np.subtract(arr[1:], arr[:-1], out=enc[1:]) return enc diff --git a/numcodecs/tests/test_delta.py b/numcodecs/tests/test_delta.py index fb5714bb..9664efee 100644 --- a/numcodecs/tests/test_delta.py +++ b/numcodecs/tests/test_delta.py @@ -14,6 +14,7 @@ # mix of shapes: 1D, 2D, 3D # mix of orders: C, F arrays = [ + np.random.randint(0, 1, size=110, dtype='?').reshape(10, 11), np.arange(1000, dtype='