Ejemplo n.º 1
0
 def test_2_dims(self):
     expected = np.vstack((np.tile(np.arange(2),
                                   3), np.repeat(np.arange(3), 2)))
     ret_val = anc_build_utils.make_indices_matrix([2, 3],
                                                   is_position=False)
     self.assertTrue(np.allclose(expected, ret_val))
     ret_val = anc_build_utils.make_indices_matrix([2, 3], is_position=True)
     self.assertTrue(np.allclose(expected.T, ret_val))
Ejemplo n.º 2
0
 def test_weird_inputs(self):
     with self.assertRaises(ValueError):
         _ = anc_build_utils.make_indices_matrix([2, 'hello', 3])
Ejemplo n.º 3
0
 def test_matrix_1_dims(self):
     expected = np.expand_dims(np.arange(4), axis=0)
     ret_val = anc_build_utils.make_indices_matrix([4], is_position=False)
     self.assertTrue(np.allclose(expected, ret_val))
     ret_val = anc_build_utils.make_indices_matrix([4], is_position=True)
     self.assertTrue(np.allclose(expected.T, ret_val))
Ejemplo n.º 4
0
 def test_non_int_dim_sizes(self):
     with self.assertRaises(ValueError):
         _ = anc_build_utils.make_indices_matrix([1.233, 2.4, 3])
Ejemplo n.º 5
0
 def test_single_value_dimension_list_input(self):
     expected = np.expand_dims(np.arange(1), axis=0)
     ret_val = anc_build_utils.make_indices_matrix([1], is_position=False)
     self.assertTrue(np.allclose(expected, ret_val))
Ejemplo n.º 6
0
 def test_empty_list(self):
     with self.assertRaises(ValueError):
         _ = anc_build_utils.make_indices_matrix([])
Ejemplo n.º 7
0
 def test_just_size_of_one_dim(self):
     expected = np.expand_dims(np.arange(4), axis=0)
     ret_val = anc_build_utils.make_indices_matrix(4, is_position=False)
     self.assertTrue(np.allclose(expected, ret_val))
Ejemplo n.º 8
0
 def test_dim_w_val_1(self):
     with self.assertRaises(ValueError):
         _ = anc_build_utils.make_indices_matrix([1, 2, 3])