Example #1
0
 def test_add_nd_array(self):
     # Check that the ElementWise functionality accepts numpy arrays,
     # and the result is as expected.
     r = biggus.add(np.arange(4), np.arange(4) * 2)
     self.assertIsInstance(r._array1, biggus.NumpyArrayAdapter)
     self.assertIsInstance(r._array2, biggus.NumpyArrayAdapter)
     assert_array_equal(r.ndarray(), [0, 3, 6, 9])
Example #2
0
 def test_add_nd_array(self):
     # Check that the ElementWise functionality accepts numpy arrays,
     # and the result is as expected.
     r = biggus.add(np.arange(4), np.arange(4) * 2)
     self.assertIsInstance(r._array1, biggus.NumpyArrayAdapter)
     self.assertIsInstance(r._array2, biggus.NumpyArrayAdapter)
     assert_array_equal(r.ndarray(), [0, 3, 6, 9])
Example #3
0
 def test_add_integer(self):
     # Check that the ElementWise functionality accepts numpy arrays,
     # and the result is as expected.
     r = biggus.add(np.arange(3) * 2, 5)
     assert_array_equal(r.ndarray(), [5, 7, 9])
Example #4
0
 def test_add_non_supported_type(self):
     # Check that the ElementWise functionality raises a TypeError
     # if neither an Array or np.ndarray is given
     with self.assertRaises(TypeError):
         biggus.add(range(12), np.arange(12))
Example #5
0
 def test_other_array(self):
     a = FakeArray([2, 4])
     b = FakeArray([2, 4])
     r = a + b
     self.assertIsInstance(r, biggus._Elementwise)
     self.assertElementwise(r, biggus.add(a, b))
Example #6
0
 def test_add_integer(self):
     # Check that the ElementWise functionality accepts numpy arrays,
     # and the result is as expected.
     r = biggus.add(np.arange(3) * 2, 5)
     assert_array_equal(r.ndarray(), [5, 7, 9])
Example #7
0
 def test_add_non_supported_type(self):
     # Check that the ElementWise functionality raises a TypeError
     # if neither an Array or np.ndarray is given
     with self.assertRaises(TypeError):
         biggus.add(range(12), np.arange(12))
Example #8
0
 def test_other_array(self):
     a = FakeArray([2, 4])
     b = FakeArray([2, 4])
     r = a + b
     self.assertIsInstance(r, biggus._Elementwise)
     self.assertElementwise(r, biggus.add(a, b))