Using scipy's brentq to solve for upper-limit