mirror of
https://github.com/rasbt/python_reference.git
synced 2024-12-18 00:00:19 +00:00
bitstring
This commit is contained in:
parent
01fbbeb69c
commit
21e4d5e813
|
@ -6,6 +6,9 @@ def make_bitstring(ary)
|
||||||
return np.where(ary > 0, 1, 0)
|
return np.where(ary > 0, 1, 0)
|
||||||
|
|
||||||
|
|
||||||
|
def faster_bitstring(ary)
|
||||||
|
return np.where(ary > 0).astype('i1')
|
||||||
|
|
||||||
### Example:
|
### Example:
|
||||||
|
|
||||||
ary1 = np.array([1, 2, 0.3, -1, -2])
|
ary1 = np.array([1, 2, 0.3, -1, -2])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user