bitstring

This commit is contained in:
rasbt 2014-09-23 13:34:17 -04:00
parent 01fbbeb69c
commit 21e4d5e813

View File

@ -6,9 +6,12 @@ def make_bitstring(ary)
return np.where(ary > 0, 1, 0)
def faster_bitstring(ary)
return np.where(ary > 0).astype('i1')
### Example:
ary1 = np.array([1, 2, 0.3, -1, -2])
make_bitstring(ary1)
# returns array([1, 1, 1, 0, 0])
# returns array([1, 1, 1, 0, 0])