mbakker7 / ttim

MIT License
34 stars 23 forks source link

Remove undefined cmath_tanh. #35

Closed Huite closed 2 years ago

Huite commented 3 years ago

Some testing also shows that numpy.tanh and cmath.tanh give the same answers now (as far as I can tell), no longer requiring special casing for abs(sqrtpSc[0]) < 200.

To illustrate:

import cmath
import numpy as np

a = np.arange(0.01, 200.0, 0.1)
b = np.tanh(a)
c = np.array([cmath.tanh(e) for e in a])

assert np.allclose(b, c.real)

This gets rid of a bug where certain resistance or storage values would result in an error, because cmath_tanh is not defined anywhere currently.

mbakker7 commented 2 years ago

Looks good. cmath.tanh was needed in the past, but numpy has been updated.