# Path: diffprivlib/validation.py
# def clip_to_norm(array, clip):
#     """Clips the examples of a 2-dimensional array to a given maximum norm.
# 
#     Parameters
#     ----------
#     array : np.ndarray
#         Array to be clipped.  After clipping, all examples have a 2-norm of at most `clip`.
# 
#     clip : float
#         Norm at which to clip each example
# 
#     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)}.")
#     if array.ndim != 2:
#         raise ValueError(f"input array must be 2-dimensional, got {array.ndim} dimensions.")
#     if not isinstance(clip, Real):
#         raise TypeError(f"Clip value must be numeric, got {type(clip)}.")
#     if clip <= 0:
#         raise ValueError(f"Clip value must be strictly positive, got {clip}.")
# 
#     norms = np.linalg.norm(array, axis=1) / clip
#     norms[norms < 1] = 1
# 
#     return array / norms[:, np.newaxis]


from unittest import TestCase
from diffprivlib.validation import clip_to_norm
        from sklearn import datasets
import numpy as np
import pytest



class TestClipToNorm(TestCase):
    def test_incorrect_parameterisation(self):
        with self.assertRaises(TypeError):
            clip_to_norm([1, 2, 3], 1)

        with self.assertRaises(ValueError):
            clip_to_norm(np.array([1, 2, 3]), 1)

        with self.assertRaises(TypeError):
            clip_to_norm(np.ones((5, 1)), complex(1, 2))

        with self.assertRaises(TypeError):

# Path: diffprivlib/validation.py
# def clip_to_norm(array, clip):
#     """Clips the examples of a 2-dimensional array to a given maximum norm.
# 
#     Parameters
#     ----------
#     array : np.ndarray
#         Array to be clipped.  After clipping, all examples have a 2-norm of at most `clip`.
# 
#     clip : float
#         Norm at which to clip each example
# 
#     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)}.")
#     if array.ndim != 2:
#         raise ValueError(f"input array must be 2-dimensional, got {array.ndim} dimensions.")
#     if not isinstance(clip, Real):
#         raise TypeError(f"Clip value must be numeric, got {type(clip)}.")
#     if clip <= 0:
#         raise ValueError(f"Clip value must be strictly positive, got {clip}.")
# 
#     norms = np.linalg.norm(array, axis=1) / clip
#     norms[norms < 1] = 1
# 
#     return array / norms[:, np.newaxis]


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




class TestClipToNorm(TestCase):
    def test_incorrect_parameterisation(self):
        with self.assertRaises(TypeError):
            clip_to_norm([1, 2, 3], 1)

        with self.assertRaises(ValueError):
            clip_to_norm(np.array([1, 2, 3]), 1)

        with self.assertRaises(TypeError):
            clip_to_norm(np.ones((5, 1)), complex(1, 2))

        with self.assertRaises(TypeError):

            clip_to_norm(np.ones((5, 1)), "1")