# Path: finitediff/grid/make.py
# def adapted_grid(xstart, xstop, cb, grid_additions=(50, 50), **kwargs):
#     """ " Creates an adapted (1D) grid by subsequent subgrid insertions.
# 
#     Parameters
#     ----------
#     xstart : float
#     xstop : float
#     cb : callbable
#         Function to be evaluated (note that noise is handled poorly).
#     grid_additions : iterable of ints (even numbers)
#         Sequence specifying how many gridpoints to add each time.
#     \\*\\*kwargs : see :func:`refine_grid`.
#     """
#     grid = np.linspace(xstart, xstop, grid_additions[0])
#     return refine_grid(grid, cb, grid_additions=grid_additions[1:], **kwargs)
# 
# Path: finitediff/grid/tests/_common.py
# def g(x):
#     s = sigm(x, 20, 1, 4)
#     s2 = sigm(x, 5, 1, 4)
#     g.nelem_call += x.size
#     g.nfev += 1
#     return 10 * (1 - s2 ** 2) * np.exp(20 * s) / np.exp(20 * x) + 0.1 * (x - 3) ** 2


import numpy as np
from ..make import adapted_grid
from ._common import g
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function



def test_adapted_grid():
    ag, y = adapted_grid(0, 2, g, (8,) * 4)
    assert ag.shape == (32,)
    assert y.shape == (32,)


def test_adapted_grid__performance():
    r = []
    for ga in [(32,), (16,) * 2, (8,) * 4]:

# Path: finitediff/grid/make.py
# def adapted_grid(xstart, xstop, cb, grid_additions=(50, 50), **kwargs):
#     """ " Creates an adapted (1D) grid by subsequent subgrid insertions.
# 
#     Parameters
#     ----------
#     xstart : float
#     xstop : float
#     cb : callbable
#         Function to be evaluated (note that noise is handled poorly).
#     grid_additions : iterable of ints (even numbers)
#         Sequence specifying how many gridpoints to add each time.
#     \\*\\*kwargs : see :func:`refine_grid`.
#     """
#     grid = np.linspace(xstart, xstop, grid_additions[0])
#     return refine_grid(grid, cb, grid_additions=grid_additions[1:], **kwargs)
# 
# Path: finitediff/grid/tests/_common.py
# def g(x):
#     s = sigm(x, 20, 1, 4)
#     s2 = sigm(x, 5, 1, 4)
#     g.nelem_call += x.size
#     g.nfev += 1
#     return 10 * (1 - s2 ** 2) * np.exp(20 * s) / np.exp(20 * x) + 0.1 * (x - 3) ** 2


# Path: finitediff/grid/tests/test_make.py
import numpy as np
from ..make import adapted_grid
from ._common import g

# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function



def test_adapted_grid():
    ag, y = adapted_grid(0, 2, g, (8,) * 4)
    assert ag.shape == (32,)
    assert y.shape == (32,)


def test_adapted_grid__performance():
    r = []
    for ga in [(32,), (16,) * 2, (8,) * 4]:

        grid, y = adapted_grid(0, 2, g, ga)