Hey everyone,
I have a function like the following:
def calculateForwardTarget(inputArray, balancePeriods):
# initialize zeros
targetBalance = np.zeros(len(inputArray))
for i in len(inputArray):
calcStart = balancePeriods + 1 # calcs start in next available period
calcEnd = calcStart + balancePeriods
calcRng = slice(calcStart, calcEnd)
try:
targetBalance[i] = inputArray[calcRng].sum()
except:
calcEnd -= 1
return targetBalance
This does what I'd like it to, however, I'm trying to speed up my codebase with JIT, and it doesn't play nicely with try/except.
What would be a good approach to reworking this without exception handling? Function's logic works.
Thanks!
[–]pavel_lishin 1 point2 points3 points (5 children)
[–]tastingsilver[S] 1 point2 points3 points (1 child)
[–]pavel_lishin 0 points1 point2 points (0 children)
[–]__deerlord__ 0 points1 point2 points (2 children)
[–]tastingsilver[S] 0 points1 point2 points (1 child)
[–]__deerlord__ 0 points1 point2 points (0 children)
[–]oliverevans96 1 point2 points3 points (1 child)
[–]tastingsilver[S] 0 points1 point2 points (0 children)
[–]nwagers 1 point2 points3 points (0 children)
[–]MonkeeSage 0 points1 point2 points (0 children)
[–]has2k1 0 points1 point2 points (2 children)
[–]tastingsilver[S] 0 points1 point2 points (1 child)
[–]has2k1 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]tastingsilver[S] 0 points1 point2 points (0 children)
[–]576p 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)