File tree Expand file tree Collapse file tree 3 files changed +9
-4
lines changed Expand file tree Collapse file tree 3 files changed +9
-4
lines changed Original file line number Diff line number Diff line change 9191from numcodecs .shuffle import Shuffle
9292register_codec (Shuffle )
9393
94+ from numcodecs .bitinfo import BitInfo
95+ register_codec (BitInfo )
96+
9497from numcodecs .bitround import BitRound
9598register_codec (BitRound )
9699
Original file line number Diff line number Diff 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
7678def exponent_bias (dtype ):
Original file line number Diff line number Diff 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 )
You can’t perform that action at this time.
0 commit comments