Subgradient calculator for Python