Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #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) 
Пример #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!")
Пример #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)
Пример #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!")
Пример #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)
Пример #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)
Пример #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)