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 91
91
from numcodecs .shuffle import Shuffle
92
92
register_codec (Shuffle )
93
93
94
+ from numcodecs .bitinfo import BitInfo
95
+ register_codec (BitInfo )
96
+
94
97
from numcodecs .bitround import BitRound
95
98
register_codec (BitRound )
96
99
Original file line number Diff line number Diff line change @@ -50,6 +50,8 @@ def encode(self, buf):
50
50
compressible.
51
51
"""
52
52
a = ensure_ndarray_like (buf )
53
+ dtype = a .dtype
54
+
53
55
if not a .dtype .kind == "f" or a .dtype .itemsize > 8 :
54
56
raise TypeError ("Only float arrays (16-64bit) can be bit-rounded" )
55
57
@@ -70,7 +72,7 @@ def encode(self, buf):
70
72
71
73
keepbits = max (keepbits )
72
74
73
- return BitRound ._bitround (a , keepbits )
75
+ return BitRound ._bitround (a , keepbits , dtype )
74
76
75
77
76
78
def exponent_bias (dtype ):
Original file line number Diff line number Diff line change @@ -59,11 +59,11 @@ def encode(self, buf):
59
59
if self .keepbits > bits :
60
60
raise ValueError ("Keepbits too large for given dtype" )
61
61
62
- return self ._bitround (a , self .keepbits )
62
+ return self ._bitround (a , self .keepbits , a . dtype )
63
63
64
64
@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 )]
67
67
a_int_dtype = np .dtype (buf .dtype .str .replace ("f" , "i" ))
68
68
all_set = np .array (- 1 , dtype = a_int_dtype )
69
69
b = buf .view (a_int_dtype )
You can’t perform that action at this time.
0 commit comments