# Path: finitediff/grid/rebalance.py
# def pre_pruning_mask(grid, rtol=1e-12, atol=0.0):
#     """Returns a mask for grid pruning.
# 
#     Any grid spacing smaller than ``rtol*gridvalue + atol`` will
#     be pruned. In general the value on the right is removed unless it is
#     the last point in the grid.
# 
#     Parameters
#     ----------
#     grid : array
#     rtol : float
#     atol : float
# 
#     Returns
#     -------
#     NumPy array of ``numpy.bool_`` (to be used as mask).
# 
#     """
#     if np.any(np.diff(grid) < 0):
#         raise ValueError("grid needs to be monotonic")
#     limit = grid[-1] - (atol + abs(rtol * grid[-1]))
#     mask = np.empty(grid.size, dtype=np.bool_)
#     mask[grid.size - 1] = True  # rightmost point included
#     for ridx in range(grid.size - 2, -1, -1):
#         if grid[ridx] < limit:
#             mask[ridx] = True
#             break
#         else:
#             mask[ridx] = False
#     else:
#         raise ValueError("no grid-points left")
#     mask[0] = True  # leftmost point included
#     limit = grid[0] + abs(rtol * grid[0]) + atol
#     for idx in range(1, ridx):
#         if grid[idx] < limit:
#             mask[idx] = False
#         else:
#             mask[idx] = True
#             limit = grid[idx] + abs(rtol * grid[idx]) + atol
#     return mask


import numpy as np
import pytest
from ..rebalance import pre_pruning_mask
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function




def test_pre_pruning_mask():
    assert np.all(pre_pruning_mask(np.array([0.0, 1e00, 2e00, 3, 4])) == [True] * 5)
    assert np.all(

# Path: finitediff/grid/rebalance.py
# def pre_pruning_mask(grid, rtol=1e-12, atol=0.0):
#     """Returns a mask for grid pruning.
# 
#     Any grid spacing smaller than ``rtol*gridvalue + atol`` will
#     be pruned. In general the value on the right is removed unless it is
#     the last point in the grid.
# 
#     Parameters
#     ----------
#     grid : array
#     rtol : float
#     atol : float
# 
#     Returns
#     -------
#     NumPy array of ``numpy.bool_`` (to be used as mask).
# 
#     """
#     if np.any(np.diff(grid) < 0):
#         raise ValueError("grid needs to be monotonic")
#     limit = grid[-1] - (atol + abs(rtol * grid[-1]))
#     mask = np.empty(grid.size, dtype=np.bool_)
#     mask[grid.size - 1] = True  # rightmost point included
#     for ridx in range(grid.size - 2, -1, -1):
#         if grid[ridx] < limit:
#             mask[ridx] = True
#             break
#         else:
#             mask[ridx] = False
#     else:
#         raise ValueError("no grid-points left")
#     mask[0] = True  # leftmost point included
#     limit = grid[0] + abs(rtol * grid[0]) + atol
#     for idx in range(1, ridx):
#         if grid[idx] < limit:
#             mask[idx] = False
#         else:
#             mask[idx] = True
#             limit = grid[idx] + abs(rtol * grid[idx]) + atol
#     return mask


# Path: finitediff/grid/tests/test_rebalance.py
import numpy as np
import pytest
from ..rebalance import pre_pruning_mask

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




def test_pre_pruning_mask():
    assert np.all(pre_pruning_mask(np.array([0.0, 1e00, 2e00, 3, 4])) == [True] * 5)
    assert np.all(

        pre_pruning_mask(np.array([0.0, 1e-14, 2e00, 3, 4]), atol=1e-12)