Skip to content

Commit 62f4987

Browse files
committed
Fixing bugs
1 parent 385f28e commit 62f4987

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

numcodecs/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@
9191
from numcodecs.shuffle import Shuffle
9292
register_codec(Shuffle)
9393

94+
from numcodecs.bitinfo import BitInfo
95+
register_codec(BitInfo)
96+
9497
from numcodecs.bitround import BitRound
9598
register_codec(BitRound)
9699

numcodecs/bitinfo.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ def encode(self, buf):
5050
compressible.
5151
"""
5252
a = ensure_ndarray_like(buf)
53+
dtype = a.dtype
54+
5355
if not a.dtype.kind == "f" or a.dtype.itemsize > 8:
5456
raise TypeError("Only float arrays (16-64bit) can be bit-rounded")
5557

@@ -70,7 +72,7 @@ def encode(self, buf):
7072

7173
keepbits = max(keepbits)
7274

73-
return BitRound._bitround(a, keepbits)
75+
return BitRound._bitround(a, keepbits, dtype)
7476

7577

7678
def exponent_bias(dtype):

numcodecs/bitround.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ def encode(self, buf):
5959
if self.keepbits > bits:
6060
raise ValueError("Keepbits too large for given dtype")
6161

62-
return self._bitround(a, self.keepbits)
62+
return self._bitround(a, self.keepbits, a.dtype)
6363

6464
@staticmethod
65-
def _bitround(buf, keepbits):
66-
bits = max_bits[str(buf.dtype)]
65+
def _bitround(buf, keepbits, dtype):
66+
bits = max_bits[str(dtype)]
6767
a_int_dtype = np.dtype(buf.dtype.str.replace("f", "i"))
6868
all_set = np.array(-1, dtype=a_int_dtype)
6969
b = buf.view(a_int_dtype)

0 commit comments

Comments
 (0)