Esempio n. 1
0
 def test_zeroes(self):
     for N in range(4):
         a = arr.array(N, N, N)
         for i in range(N):
             for j in range(N):
                 for k in range(N):
                     self.assertEqual(a[i, j, k], 0)
Esempio n. 2
0
 def test_zeroes(self):
     for N in range(4):
         a = arr.array(N, N, N)
         for i in range(N):
             for j in range(N):
                 for h in range(N):
                     self.assertEqual(a[i, j, h], 0)
Esempio n. 3
0
 def testIdentity(self):
     for N in range(4):
         a = arr.array(N, N)
         for i in range(N):
             a[i, i]  = 1
         for i in range(N):
             for j in range(N):
                 self.assertEqual(a[i, j], i == j)
Esempio n. 4
0
 def test_key_validity(self):
     a = arr.array(10, 10, 10)
     self.assertRaises(KeyError, self._index, a, -1, 1, 1)
     self.assertRaises(KeyError, self._index, a, 10, 1, 1)
     self.assertRaises(KeyError, self._index, a, 1, -1, 1)
     self.assertRaises(KeyError, self._index, a, 1, 10, 1)
     self.assertRaises(KeyError, self._index, a, 1, 1, -1)
     self.assertRaises(KeyError, self._index, a, 1, 1, 10)
Esempio n. 5
0
 def test_key_validity(self):
     print("Key")
     a = arr.array(10, 10)
     print()
     self.assertRaises(KeyError, self._index, a, 10, 10)
     self.assertRaises(KeyError, self._index, a, -1, 1)
     self.assertRaises(KeyError, self._index, a, 10, 1)
     self.assertRaises(KeyError, self._index, a, 1, -1)
     self.assertRaises(KeyError, self._index, a, 1, 10)
Esempio n. 6
0
 def test_identity(self):
     print("Identity")
     for N in range(4):
         a = arr.array(N, N)
         for i in range(N):
             a[i, i] = 1
         for i in range(N):
             for j in range(N):
                 self.assertEqual(a[i, j], i == j)
Esempio n. 7
0
 def test_identity(self):
     for N in range(4):
         a = arr.array(N, N, N)
         for i in range(N):
             a[i, i, i] = 1
         for i in range(N):
             for j in range(N):
                 for k in range(N):
                     self.assertEqual(a[i, j, k], i == j and j == k)
Esempio n. 8
0
 def test_identity(self):
     for N in range(4):
         a = arr.array(N, N, N)
         for i in range(N):
             a[i, i, i] = 1
         for i in range(N):
             for j in range(N):
                 for h in range(N):
                     self.assertEqual(a[i, j, h], i == j == h)
Esempio n. 9
0
 def test_key_validity(self):
     a = arr.array(10, 10, 10)
     self.assertRaises(KeyError, self._index, a, -1, 1, 1)
     self.assertRaises(KeyError, self._index, a, 10, 1, 1)
     self.assertRaises(KeyError, self._index, a, 1, -1, 1)
     self.assertRaises(KeyError, self._index, a, 1, 10, 1)
     self.assertRaises(KeyError, self._index, a, 1, 1, -1)
     self.assertRaises(KeyError, self._index, a, 1, 1, 10)
     self.assertRaises(arr.DimensionalArrayError, self._index_error, a, 1, 1)
     self.assertRaises(arr.DimensionalArrayError, self._index_errror2, a, 1, 1, 1, 1)
Esempio n. 10
0
 def test_key_validity(self):
     """
     Validate key for row, column and depth
     """
     a = arr.array(10, 10, 10)
     self.assertRaises(KeyError, self._index, a, -1, 1, 1)
     self.assertRaises(KeyError, self._index, a, 10, 1, 1)
     self.assertRaises(KeyError, self._index, a, 1, -1, 1)
     self.assertRaises(KeyError, self._index, a, 1, 10, 1)
     self.assertRaises(KeyError, self._index, a, 1, 1, -1)
Esempio n. 11
0
 def test_key_validity(self):
     """ test confirms KeyError is raised for index range < 0 or 
         greater than max index of dimension """
     a = arr.array(10, 10, 10)
     self.assertRaises(KeyError, self._index, a, -1, 1, 1)
     self.assertRaises(KeyError, self._index, a, 1, -1, 1)
     self.assertRaises(KeyError, self._index, a, 1, 1, -1)
     self.assertRaises(KeyError, self._index, a, 10, 1, 1)
     self.assertRaises(KeyError, self._index, a, 1, 10, 1)
     self.assertRaises(KeyError, self._index, a, 1, 1, 10) 
Esempio n. 12
0
 def test_zeros(self):
     """
     All array elements should be zero
     """
     for N in range(4):
         a = arr.array(N, N, N)
         for i in range(N):
             for j in range(N):
                 for k in range(N):
                     self.assertEqual(a[i, j, k], 0, "Expecting a zero!")
Esempio n. 13
0
 def test_identity(self):
     """creates an array of each size and verifies each as an identity matrix,
        where the value in location i, j, k, where i=j=k, is one, and zero elsewhere"""
     for N in range(4):
         a = arr.array(N, N, N)
         for i in range(N):
             a[i, i, i] = 1
         for i in range(N):
             for j in range(N):
                 for k in range(N):
                     self.assertEqual(a[i, j, k], i==j==k)
Esempio n. 14
0
 def test_identity(self):
     """
     Identity matrix should be one
     """
     for N in range(4):
         a = arr.array(N, N, N)
         for i in range(N):
             a[i, i, i] = 1
         for i in range(N):
             for j in range(N):
                 for k in range(N):
                     self.assertEqual(a[i, j, k], i==j==k, "Expecting a one!")
Esempio n. 15
0
 def test_identity(self):
     for N in range(4):
         a = arr.array(N, N)
         for i in range(N):
             a[i, i] = 1
             print(i, "a")
             print(a[i, i], "b")
         for i in range(N):
             for j in range(N):
                 print(a[i,j], "c")
                 print(i == j, "d")
                 self.assertEqual(a[i, j], i==j)
Esempio n. 16
0
 def test_key_validity(self):
     a = arr.array(5, 5, 5)
     self.assertRaises(KeyError, self._index, a, -1, 3, 4)
     self.assertRaises(KeyError, self._index, a, 2, 3, 10)
Esempio n. 17
0
 def test_key_validity(self):
     a = arr.array(5, 5, 5)
     self.assertRaises(KeyError, self._index, a, -1, 3, 4)
     self.assertRaises(KeyError, self._index, a, 2, 3, 10)