File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,12 @@ def __init__(self, value):
77 if isinstance (value , str ):
88 self ._value = self .from_text (value )._value
99 else :
10- # TODO use np.unpackbits for uint8 array
10+ # TODO change in 0.4.0
11+ # if isinstance(value, np.ndarray) and value.dtype == np.uint8:
12+ # value = np.unpackbits(value)
13+ # else:
14+ # value = np.asarray(value, dtype=bool)
15+
1116 value = np .asarray (value , dtype = bool )
1217
1318 if value .ndim != 1 :
Original file line number Diff line number Diff line change @@ -13,6 +13,12 @@ def test_tuple(self):
1313 def test_str (self ):
1414 assert Bit ('101' ).to_list () == [True , False , True ]
1515
16+ def test_ndarray_uint8 (self ):
17+ arr = np .array ([254 , 7 , 0 ], dtype = np .uint8 )
18+ # TODO change in 0.4.0
19+ # assert Bit(arr).to_text() == '111111100000011100000000'
20+ assert Bit (arr ).to_text () == '110'
21+
1622 def test_ndarray_same_object (self ):
1723 arr = np .array ([True , False , True ])
1824 assert Bit (arr ).to_list () == [True , False , True ]
You can’t perform that action at this time.
0 commit comments