<commit_before>#!/usr/bin/env python
# Created by <NAME>, <NAME>, 2007
""" Test functions for rbf module """

from numpy.testing import assert_array_almost_equal
from numpy import linspace, sin, random, exp


from scipy.interpolate.rbf import Rbf


def test_rbf1d():
    x = linspace(0,10,9)
    y = sin(x)
    rbf = Rbf(x, y)
    yi = rbf(x)
    assert_array_almost_equal(y, yi)

def test_rbf2d():
    x = random.rand(50,1)*4-2
    y = random.rand(50,1)*4-2
    z = x*exp(-x**2-y**2)
    rbf = Rbf(x, y, z ,epsilon=2)
    zi = rbf(x, y)
    zi.shape = x.shape
    assert_array_almost_equal(z, zi)

def test_rbf3d():
    x = random.rand(50,1)*4-2
    y = random.rand(50,1)*4-2
    z = random.rand(50,1)*4-2
    d = x*exp(-x**2-y**2)
    rbf = Rbf(x, y, z, d ,epsilon=2)
    di = rbf(x, y, z)
    di.shape = x.shape
    assert_array_almost_equal(di, d)

if __name__ == "__main__":
    run_module_suite()<commit_msg>interpolate.Rbf: Test all available basis functions<commit_after>#!/usr/bin/env python
# Created by <NAME>, <NAME>, 2007
""" Test functions for rbf module """

from numpy.testing import assert_array_almost_equal
from numpy import linspace, sin, random, exp
from scipy.interpolate.rbf import Rbf

FUNCTIONS = ('multiquadric', 'inverse multiquadric', 'gaussian',
             'cubic', 'quintic', 'thin-plate')

def check_rbf1d(function):
    x = linspace(0,10,9)
    y = sin(x)
    rbf = Rbf(x, y, function=function)
    yi = rbf(x)
    assert_array_almost_equal(y, yi)

def check_rbf2d(function):
    x = random.rand(50,1)*4-2
    y = random.rand(50,1)*4-2
    z = x*exp(-x**2-y**2)
    rbf = Rbf(x, y, z, epsilon=2, function=function)
    zi = rbf(x, y)
    zi.shape = x.shape
    assert_array_almost_equal(z, zi)

def check_rbf3d(function):
    x = random.rand(50,1)*4-2
    y = random.rand(50,1)*4-2
    z = random.rand(50,1)*4-2
    d = x*exp(-x**2-y**2)
    rbf = Rbf(x, y, z, d, epsilon=2, function=function)
    di = rbf(x, y, z)
    di.shape = x.shape
    assert_array_almost_equal(di, d)

def test_rbf_interpolation():
    for function in FUNCTIONS:
        yield check_rbf1d, function
        yield check_rbf2d, function
        yield check_rbf3d, function
{'fraction_non_alphanumeric': 0.15282239559430932, 'fraction_numerical': 0.039926571821936666, 'mean_word_length': 3.249512670565302, 'pattern_counts': {'":': 1, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '347822', 'n_tokens_mistral': 945, 'n_tokens_neox': 908, 'n_words': 202}