# Path: diffprivlib/validation.py
# def clip_to_bounds(array, bounds):
#     """Clips the examples of a 2-dimensional array to given bounds.
# 
#     Parameters
#     ----------
#     array : np.ndarray
#         Array to be clipped.  After clipping, all examples have a 2-norm of at most `clip`.
# 
#     bounds : tuple
#         Tuple of bounds of the form (min, max) which the array is to be clipped to. `min` and `max` must be scalar,
#         unless array is 2-dimensional.
# 
#     Returns
#     -------
#     array : np.ndarray
#         The clipped array.
# 
#     """
#     if not isinstance(array, np.ndarray):
#         raise TypeError(f"Input array must be a numpy array, got {type(array)}.")
# 
#     lower, upper = check_bounds(bounds, np.size(bounds[0]), min_separation=0)
#     clipped_array = array.copy()
# 
#     if np.allclose(lower, np.min(lower)) and np.allclose(upper, np.max(upper)):
#         clipped_array = np.clip(clipped_array, np.min(lower), np.max(upper))
#     else:
#         if array.ndim != 2:
#             raise ValueError(f"For non-scalar bounds, input array must be 2-dimensional. Got {array.ndim} dimensions.")
# 
#         for feature in range(array.shape[1]):
#             clipped_array[:, feature] = np.clip(array[:, feature], lower[feature], upper[feature])
# 
#     return clipped_array


from unittest import TestCase
from diffprivlib.validation import clip_to_bounds
        from sklearn import datasets
import numpy as np
import pytest
        X3 = clip_to_bounds(X, (0, 2))
        self.assertTrue(np.all(X3 == X))

        X4 = X.copy()
        X4[0] = 2
        X5 = clip_to_bounds(X4, (0, 1))
        self.assertTrue(np.all(X5 == X))

    def test_3d_array(self):
        X = np.ones(shape=(2, 2, 2))
        self.assertRaises(ValueError, clip_to_bounds, X, ([0, 0.5], [0, 0.5]))

    @pytest.mark.filterwarnings('ignore: numpy.ufunc size changed')
    def test_iris(self):
        dataset = datasets.load_iris()

        X_train, y_train = dataset.data, dataset.target

        maxes = np.max(X_train, axis=1)
        clip_max = (maxes[0] + maxes[1]) / 2

        X_clipped = clip_to_bounds(X_train, (np.min(X_train), clip_max))
        clipped_maxes = np.max(X_clipped, axis=0)
        self.assertLessEqual(clipped_maxes[0], maxes[0])
        self.assertLessEqual(clipped_maxes[1], maxes[1])
        self.assertTrue(np.isclose(clipped_maxes[0], clip_max) or np.isclose(clipped_maxes[1], clip_max))

    def test_different_bounds(self):
        X = np.ones((10, 2))


# Path: diffprivlib/validation.py
# def clip_to_bounds(array, bounds):
#     """Clips the examples of a 2-dimensional array to given bounds.
# 
#     Parameters
#     ----------
#     array : np.ndarray
#         Array to be clipped.  After clipping, all examples have a 2-norm of at most `clip`.
# 
#     bounds : tuple
#         Tuple of bounds of the form (min, max) which the array is to be clipped to. `min` and `max` must be scalar,
#         unless array is 2-dimensional.
# 
#     Returns
#     -------
#     array : np.ndarray
#         The clipped array.
# 
#     """
#     if not isinstance(array, np.ndarray):
#         raise TypeError(f"Input array must be a numpy array, got {type(array)}.")
# 
#     lower, upper = check_bounds(bounds, np.size(bounds[0]), min_separation=0)
#     clipped_array = array.copy()
# 
#     if np.allclose(lower, np.min(lower)) and np.allclose(upper, np.max(upper)):
#         clipped_array = np.clip(clipped_array, np.min(lower), np.max(upper))
#     else:
#         if array.ndim != 2:
#             raise ValueError(f"For non-scalar bounds, input array must be 2-dimensional. Got {array.ndim} dimensions.")
# 
#         for feature in range(array.shape[1]):
#             clipped_array[:, feature] = np.clip(array[:, feature], lower[feature], upper[feature])
# 
#     return clipped_array


# Path: tests/test_clip_to_bounds.py
from unittest import TestCase
from diffprivlib.validation import clip_to_bounds
        from sklearn import datasets
import numpy as np
import pytest

        X3 = clip_to_bounds(X, (0, 2))
        self.assertTrue(np.all(X3 == X))

        X4 = X.copy()
        X4[0] = 2
        X5 = clip_to_bounds(X4, (0, 1))
        self.assertTrue(np.all(X5 == X))

    def test_3d_array(self):
        X = np.ones(shape=(2, 2, 2))
        self.assertRaises(ValueError, clip_to_bounds, X, ([0, 0.5], [0, 0.5]))

    @pytest.mark.filterwarnings('ignore: numpy.ufunc size changed')
    def test_iris(self):
        dataset = datasets.load_iris()

        X_train, y_train = dataset.data, dataset.target

        maxes = np.max(X_train, axis=1)
        clip_max = (maxes[0] + maxes[1]) / 2

        X_clipped = clip_to_bounds(X_train, (np.min(X_train), clip_max))
        clipped_maxes = np.max(X_clipped, axis=0)
        self.assertLessEqual(clipped_maxes[0], maxes[0])
        self.assertLessEqual(clipped_maxes[1], maxes[1])
        self.assertTrue(np.isclose(clipped_maxes[0], clip_max) or np.isclose(clipped_maxes[1], clip_max))

    def test_different_bounds(self):
        X = np.ones((10, 2))


        X_clipped = clip_to_bounds(X, ([0, 0], [0.5, 1]))