コード例 #1
0
ファイル: test_hankel.py プロジェクト: ng110/pyhank
def test_round_trip_k_interpolation(radius: np.ndarray, order: int, shape: Callable):
    k_grid = radius/10
    transformer = HankelTransform(order=order, k_grid=k_grid)

    # the function must be smoothish for interpolation
    # to work. Random every point doesn't work
    func = shape(k_grid)
    transform_func = transformer.to_transform_k(func)
    reconstructed_func = transformer.to_original_k(transform_func)
    assert np.allclose(func, reconstructed_func, rtol=1e-4)
コード例 #2
0
ファイル: test_hankel.py プロジェクト: etfrogers/pyhank
def test_round_trip_k_interpolation_2d(radius: np.ndarray, order: int,
                                       shape: Callable, axis: int):
    k_grid = radius / 10
    transformer = HankelTransform(order=order, k_grid=k_grid)

    # the function must be smoothish for interpolation
    # to work. Random every point doesn't work
    dims_amplitude = np.ones(2, np.int)
    dims_amplitude[1 - axis] = 10
    amplitude = np.random.random(dims_amplitude)
    dims_k = np.ones(2, np.int)
    dims_k[axis] = len(radius)
    func = np.reshape(shape(k_grid), dims_k) * np.reshape(
        amplitude, dims_amplitude)
    transform_func = transformer.to_transform_k(func, axis=axis)
    reconstructed_func = transformer.to_original_k(transform_func, axis=axis)
    assert np.allclose(func, reconstructed_func, rtol=1e-4)