# 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/util.py
# def locate_discontinuity(grid, y, consider, trnsfm=lambda x: x, ntrail=2):
#     y = np.asarray(y, dtype=np.float64)
#     dy = np.diff(y)
#     tg = trnsfm(grid)
#     dtg = np.diff(tg)
#     err = np.zeros(y.size)
#     for d in ("fw", "bw"):
#         est, slc = interpolate_ahead(tg, y, ntrail, d)
#         start = (ntrail - 1) if d == "fw" else 0
#         stop = -(ntrail - 1) if d == "bw" else None
#         err[slc] += np.abs(y[slc] - est) / dtg[start:stop] * dy[start:stop]
#     imax = np.argsort(err)[-consider:][::-1]
#     return [(tg[m], err[m]) for m in imax]
# 
# def pool_discontinuity_approx(loc_res, consistency_criterion=10):
#     points = np.array(loc_res)
#     w1 = np.abs(points[:, 1])
#     return avg_stddev(points[:, 0], w1)
# 
# Path: finitediff/grid/tests/_common.py
# def sigm(x, m, o, n):
# def g(x):
# def g2(x):


from .. import adapted_grid
from ..util import locate_discontinuity, pool_discontinuity_approx
from ._common import g3


def test_locate_discontinuity__pool_discontinuity_approx():
    for snr in [False, True]:
        loc_res = locate_discontinuity(

# 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/util.py
# def locate_discontinuity(grid, y, consider, trnsfm=lambda x: x, ntrail=2):
#     y = np.asarray(y, dtype=np.float64)
#     dy = np.diff(y)
#     tg = trnsfm(grid)
#     dtg = np.diff(tg)
#     err = np.zeros(y.size)
#     for d in ("fw", "bw"):
#         est, slc = interpolate_ahead(tg, y, ntrail, d)
#         start = (ntrail - 1) if d == "fw" else 0
#         stop = -(ntrail - 1) if d == "bw" else None
#         err[slc] += np.abs(y[slc] - est) / dtg[start:stop] * dy[start:stop]
#     imax = np.argsort(err)[-consider:][::-1]
#     return [(tg[m], err[m]) for m in imax]
# 
# def pool_discontinuity_approx(loc_res, consistency_criterion=10):
#     points = np.array(loc_res)
#     w1 = np.abs(points[:, 1])
#     return avg_stddev(points[:, 0], w1)
# 
# Path: finitediff/grid/tests/_common.py
# def sigm(x, m, o, n):
# def g(x):
# def g2(x):


# Path: finitediff/grid/tests/test_util.py
from .. import adapted_grid
from ..util import locate_discontinuity, pool_discontinuity_approx
from ._common import g3



def test_locate_discontinuity__pool_discontinuity_approx():
    for snr in [False, True]:
        loc_res = locate_discontinuity(

            *adapted_grid(0, 10, g3, grid_additions=(16,) * 8, snr=snr), consider=5