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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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!")
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)
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!")
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)
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)