HEX
Server: Apache/2.4.46 (Win64) OpenSSL/1.1.1j PHP/8.4.25
System: Windows NT DESKTOP-4TAV2RJ 10.0 build 19045 (Windows 10) AMD64
User: fred (0)
PHP: 8.4.25
Disabled: NONE
Upload Files
File: C:/Users/fred/anaconda3/Lib/site-packages/skimage/_shared/tests/test_fast_exp.py
from ..fast_exp import fast_exp
import numpy as np


def test_fast_exp():
    X = np.linspace(-5, 0, 5000, endpoint=True)

    # Ground truth
    Y = np.exp(X)

    # Approximation at double precision
    _y_f64 = np.array([fast_exp['float64_t'](x) for x in X])

    # Approximation at single precision
    _y_f32 = np.array(
        [fast_exp['float32_t'](x) for x in X.astype('float32')], dtype='float32'
    )

    for _y in [_y_f64, _y_f32]:
        assert np.abs(Y - _y).mean() < 3e-3