Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. from functools import reduce
  2. import numpy as np
  3.  
  4. def mor(x):
  5. """x: iterable of np.array."""
  6. return reduce(np.logical_or, x)
  7.  
  8. def mand(x):
  9. """x: iterable of np.array."""
  10. return reduce(np.logical_and, x)
  11.  
  12. def madd(x):
  13. """Performs element-wise string concatenation with multiple input arrays.
  14.  
  15. Args:
  16. x: iterable of np.array.
  17.  
  18. Returns: np.array.
  19. """
  20. for i, arr in enumerate(x):
  21. if type(arr.item(0)) is not str:
  22. x[i] = x[i].astype(str)
  23. return reduce(np.core.defchararray.add, x)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement