import math
import dpnp
import numpy


def test_erf():
    a = numpy.linspace(2.0, 3.0, num=10)
    ia = dpnp.linspace(2.0, 3.0, num=10)

    numpy.testing.assert_array_equal(a, ia)

    expected = numpy.empty_like(a)
    for idx, val in enumerate(a):
        expected[idx] = math.erf(val)

    result = dpnp.erf(ia)

    numpy.testing.assert_array_equal(result, expected)


def test_erf_fallback():
    a = numpy.linspace(2.0, 3.0, num=10)

    expected = numpy.empty_like(a)
    for idx, val in enumerate(a):
        expected[idx] = math.erf(val)

    result = dpnp.erf(a)

    numpy.testing.assert_array_equal(result, expected)
