Exemple #1
0
def test_vectorize_if_needed():
    """
    Test :func:`astropy.cosmology.utils.vectorize_if_needed`.
    There's no need to test 'veckw' because that is directly pasased to
    `numpy.vectorize` which thoroughly tests the various inputs.

    """
    func = lambda x: x ** 2

    # not vectorized
    assert vectorize_if_needed(func, 2) == 4

    # vectorized
    assert all(vectorize_if_needed(func, [2, 3]) == [4, 9])
Exemple #2
0
def test_vectorize_if_needed():
    """
    Test :func:`astropy.cosmology.utils.vectorize_if_needed`.
    There's no need to test 'veckw' because that is directly pasased to
    `numpy.vectorize` which thoroughly tests the various inputs.

    """
    def func(x):
        return x ** 2

    with pytest.warns(AstropyDeprecationWarning):
        # not vectorized
        assert vectorize_if_needed(func, 2) == 4
        # vectorized
        assert all(vectorize_if_needed(func, [2, 3]) == [4, 9])