I have a 2d list comprehension which sets either 1 or 0, depending on the first occouring condition.
Since it's relatively slow, I wonder whether there is a NumPy function or a library to speed this up to a more efficient manner.
Note: the subarrays only equal length at the same index.
result = [
[1 if (ratUp >ratDown) else 0 if (ratDown>ratUp) else 0 if (pointsDown>pointsUp) else 1
for ratUp,ratDown,pointsUp,pointsDown
in zip(ratiosUpSlice,ratiosDownSlice,upPointsSlice,downPointsSlice)]
for ratiosUpSlice,ratiosDownSlice,upPointsSlice,downPointsSlice
in zip(RatiosUp, RatiosDown, UpPointsSlices, DownPointsSlices)]
Reproducable:
import numpy as np
LEN = 10000
temp = np.random.randint(1,high=100, size=LEN)
RatiosUp = [np.random.uniform(size=rand) for rand in temp]
RatiosDown = [np.random.uniform(size=rand) for rand in temp]
UpPointsSlices = [np.random.uniform(size=rand) for rand in temp]
DownPointsSlices = [np.random.uniform(size=rand) for rand in temp]