code: def test_projection(self):
      # Get MNIST
      (x, _), (_, _), _, _ = load_mnist()
  
      # Probably don't need to test everything
      x = x[:100]
      t = tuple(range(1, len(x.shape)))
      rand_sign = 1 - 2 * np.random.randint(0, 2, size=x.shape)
  
      x_proj = projection(rand_sign * x, 3.14159, 1)
      self.assertEqual(x.shape, x_proj.shape)
      self.assertTrue(
          np.allclose(
              np.sum(np.abs(x_proj), axis=t), 3.14159, atol=10e-8
          )
      )
  
      x_proj = projection(rand_sign * x, 3.14159, 2)
      self.assertEqual(x.shape, x_proj.shape)
      self.assertTrue(
          np.allclose(
              np.sqrt(np.sum(x_proj**2, axis=t)), 3.14159, atol=10e-8
          )
      )
  
      x_proj = projection(rand_sign * x, 0.314159, np.inf)
      self.assertEqual(x.shape, x_proj.shape)
      self.assertEqual(x_proj.min(), -0.314159)
      self.assertEqual(x_proj.max(), 0.314159)
  
      x_proj = projection(rand_sign * x, 3.14159, np.inf)
      self.assertEqual(x.shape, x_proj.shape)
      self.assertEqual(x_proj.min(), -1.0)
      self.assertEqual(x_proj.max(), 1.0)
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  import unittest
  import numpy
  import tensorflow
  from art.utils import projection, random_sphere, uniform_sample_from_sphere_or_ball, to_categorical, least_likely_class
  from art.utils import load_dataset, load_iris, load_mnist, load_nursery, load_cifar10
  from art.utils import second_most_likely_class, random_targets, get_label_conf, get_labels_np_array, preprocess
  from art.utils import compute_success_array, compute_success, check_and_transform_label_format
  from art.utils import segment_by_class, performance_diff
  from art.utils import is_probability
  from tests.utils import master_seed
label_desc: Use image node_id 8 for calling the TestUtils obj's underlying member method code with example usage: obj.test_projection() without return types