File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11from __future__ import annotations
22import numpy as np
33from struct import pack , unpack_from
4- from typing import Any
54from warnings import warn
65
76
87class Bit :
9- def __init__ (self , value : Any ) -> None :
8+ def __init__ (self , value : object ) -> None :
109 if isinstance (value , bytes ):
1110 self ._len = 8 * len (value )
1211 self ._data = value
@@ -16,12 +15,18 @@ def __init__(self, value: Any) -> None:
1615 else :
1716 value = np .asarray (value )
1817
18+ # for mypy
19+ assert isinstance (value , np .ndarray )
20+
1921 if value .dtype != np .bool :
2022 # skip warning for result of np.unpackbits
2123 if value .dtype != np .uint8 or np .any (value > 1 ):
2224 warn ('expected elements to be boolean' , stacklevel = 2 )
2325 value = value .astype (bool )
2426
27+ # for mypy
28+ assert isinstance (value , np .ndarray )
29+
2530 if value .ndim != 1 :
2631 raise ValueError ('expected ndim to be 1' )
2732
You can’t perform that action at this time.
0 commit comments