Beispiel #1
0
 def test_array_axis_index_out_of_bounds_single_axis(self):
     # Test too large frist axis
     d1 = np.arange(10).reshape(2, 5)
     d2 = np.arange(20).reshape(5, 2, 2)
     res = ShapeValidator.assertEqualShape(d1, d2, 4, 1)
     self.assertFalse(res.result)
     self.assertEquals(res.error, 'AXIS_OUT_OF_BOUNDS')
     self.assertTupleEqual(res.ignored, ())
     self.assertTupleEqual(res.unmatched, ())
     self.assertTupleEqual(res.shape1, (2, 5))
     self.assertTupleEqual(res.shape2, (5, 2, 2))
     self.assertTupleEqual(res.axes1, (4,))
     self.assertTupleEqual(res.axes2, (1,))
Beispiel #2
0
 def test_array_unequal_number_of_dimenions_check_multiple_axesy(self):
     # Test unequal num dims compare multiple axes
     d1 = np.arange(10).reshape(2, 5)
     d2 = np.arange(20).reshape(5, 2, 2)
     res = ShapeValidator.assertEqualShape(d1, d2, [0, 1], [1, 0])
     self.assertTrue(res.result)
     self.assertIsNone(res.error)
     self.assertTupleEqual(res.ignored, ())
     self.assertTupleEqual(res.unmatched, ())
     self.assertTupleEqual(res.shape1, (2, 5))
     self.assertTupleEqual(res.shape2, (5, 2, 2))
     self.assertTupleEqual(res.axes1, (0, 1))
     self.assertTupleEqual(res.axes2, (1, 0))
Beispiel #3
0
 def test_array_unequal_number_of_axes_for_comparison(self):
     # Test unequal num axes for comparions
     d1 = np.arange(10).reshape(2, 5)
     d2 = np.arange(20).reshape(5, 2, 2)
     res = ShapeValidator.assertEqualShape(d1, d2, [0, 1], 1)
     self.assertFalse(res.result)
     self.assertEquals(res.error, "NUM_AXES_ERROR")
     self.assertTupleEqual(res.ignored, ())
     self.assertTupleEqual(res.unmatched, ())
     self.assertTupleEqual(res.shape1, (2, 5))
     self.assertTupleEqual(res.shape2, (5, 2, 2))
     self.assertTupleEqual(res.axes1, (0, 1))
     self.assertTupleEqual(res.axes2, (1,))
Beispiel #4
0
 def test_array_unequal_number_of_dimensions(self):
     # Test unequal num dims
     d1 = np.arange(10).reshape(2, 5)
     d2 = np.arange(20).reshape(5, 2, 2)
     res = ShapeValidator.assertEqualShape(d1, d2)
     self.assertFalse(res.result)
     self.assertEquals(res.error, 'NUM_AXES_ERROR')
     self.assertTupleEqual(res.ignored, ())
     self.assertTupleEqual(res.unmatched, ())
     self.assertTupleEqual(res.shape1, (2, 5))
     self.assertTupleEqual(res.shape2, (5, 2, 2))
     self.assertTupleEqual(res.axes1, (0, 1))
     self.assertTupleEqual(res.axes2, (0, 1, 2))
Beispiel #5
0
 def test_array_unequal_number_of_dimenions_check_one_axis_only(self):
     # Test unequal num dims compare one axis
     d1 = np.arange(10).reshape(2, 5)
     d2 = np.arange(20).reshape(2, 5, 2)
     res = ShapeValidator.assertEqualShape(d1, d2, 0, 0)
     self.assertTrue(res.result)
     self.assertIsNone(res.error)
     self.assertTupleEqual(res.ignored, ())
     self.assertTupleEqual(res.unmatched, ())
     self.assertTupleEqual(res.shape1, (2, 5))
     self.assertTupleEqual(res.shape2, (2, 5, 2))
     self.assertTupleEqual(res.axes1, (0,))
     self.assertTupleEqual(res.axes2, (0,))
Beispiel #6
0
 def test_array_dimensions_mismatch(self):
     # Test unmatched
     d1 = np.arange(10).reshape(2, 5)
     d2 = np.arange(10).reshape(5, 2)
     res = ShapeValidator.assertEqualShape(d1, d2)
     self.assertFalse(res.result)
     self.assertEqual(res.error, 'AXIS_LEN_ERROR')
     self.assertTupleEqual(res.ignored, ())
     self.assertTupleEqual(res.unmatched, ((0, 0), (1, 1)))
     self.assertTupleEqual(res.shape1, (2, 5))
     self.assertTupleEqual(res.shape2, (5, 2))
     self.assertTupleEqual(res.axes1, (0, 1))
     self.assertTupleEqual(res.axes2, (0, 1))
Beispiel #7
0
 def test_DataChunkIterator_error_on_undetermined_axis(self):
     # Compare data chunk iterators with undetermined axis (error on undetermined axis)
     d1 = DataChunkIterator(data=np.arange(10).reshape(2, 5), maxshape=(None, 5))
     d2 = DataChunkIterator(data=np.arange(10).reshape(2, 5))
     res = ShapeValidator.assertEqualShape(d1, d2, ignore_undetermined=False)
     self.assertFalse(res.result)
     self.assertEquals(res.error, 'AXIS_LEN_ERROR')
     self.assertTupleEqual(res.ignored, ())
     self.assertTupleEqual(res.unmatched, ((0, 0),))
     self.assertTupleEqual(res.shape1, (None, 5))
     self.assertTupleEqual(res.shape2, (2, 5))
     self.assertTupleEqual(res.axes1, (0, 1))
     self.assertTupleEqual(res.axes2, (0, 1))
Beispiel #8
0
 def test_DataChunkIterator_ignore_undetermined_axis(self):
     # Compare data chunk iterators with undetermined axis (ignore axis)
     d1 = DataChunkIterator(data=np.arange(10).reshape(2, 5), maxshape=(None, 5))
     d2 = DataChunkIterator(data=np.arange(10).reshape(2, 5))
     res = ShapeValidator.assertEqualShape(d1, d2, ignore_undetermined=True)
     self.assertTrue(res.result)
     self.assertIsNone(res.error)
     self.assertTupleEqual(res.ignored, ((0, 0),))
     self.assertTupleEqual(res.unmatched, ())
     self.assertTupleEqual(res.shape1, (None, 5))
     self.assertTupleEqual(res.shape2, (2, 5))
     self.assertTupleEqual(res.axes1, (0, 1))
     self.assertTupleEqual(res.axes2, (0, 1))
Beispiel #9
0
 def test_array_all_dimensions_match(self):
     # Test match
     d1 = np.arange(10).reshape(2, 5)
     d2 = np.arange(10).reshape(2, 5)
     res = ShapeValidator.assertEqualShape(d1, d2)
     self.assertTrue(res.result)
     self.assertIsNone(res.error)
     self.assertTupleEqual(res.ignored, ())
     self.assertTupleEqual(res.unmatched, ())
     self.assertTupleEqual(res.shape1, (2, 5))
     self.assertTupleEqual(res.shape2, (2, 5))
     self.assertTupleEqual(res.axes1, (0, 1))
     self.assertTupleEqual(res.axes2, (0, 1))
Beispiel #10
0
 def test_DataChunkIterators_match(self):
     # Compare data chunk iterators
     d1 = DataChunkIterator(data=np.arange(10).reshape(2, 5))
     d2 = DataChunkIterator(data=np.arange(10).reshape(2, 5))
     res = ShapeValidator.assertEqualShape(d1, d2)
     self.assertTrue(res.result)
     self.assertIsNone(res.error)
     self.assertTupleEqual(res.ignored, ())
     self.assertTupleEqual(res.unmatched, ())
     self.assertTupleEqual(res.shape1, (2, 5))
     self.assertTupleEqual(res.shape2, (2, 5))
     self.assertTupleEqual(res.axes1, (0, 1))
     self.assertTupleEqual(res.axes2, (0, 1))