def test_raise(self): with self.assertRaises(ValueError): array = np.ones(5) util.array2image(array) with self.assertRaises(ValueError): array = np.ones((2, 2)) util.array2cube(array, 2, 2) with self.assertRaises(ValueError): x, y = np.ones(6), np.ones(6) util.get_axes(x, y) with self.assertRaises(ValueError): util.selectBest(array=np.ones(6), criteria=np.ones(5), numSelect=1, highest=True) with self.assertRaises(ValueError): util.select_best(array=np.ones(6), criteria=np.ones(5), num_select=1, highest=True) with self.assertRaises(ValueError): util.convert_bool_list(n=2, k=[3, 7]) with self.assertRaises(ValueError): util.convert_bool_list(n=3, k=[True, True]) with self.assertRaises(ValueError): util.convert_bool_list(n=2, k=[0.1, True])
def test_raise(self): with self.assertRaises(ValueError): array = np.ones(5) util.array2image(array) with self.assertRaises(ValueError): x, y = np.ones(6), np.ones(6) util.get_axes(x, y) with self.assertRaises(ValueError): util.selectBest(array=np.ones(6), criteria=np.ones(5), numSelect=1, highest=True) with self.assertRaises(ValueError): util.select_best(array=np.ones(6), criteria=np.ones(5), num_select=1, highest=True)
def test_select_best(): array = np.array([4, 3, 6, 1, 3]) select = np.array([2, 4, 7, 3, 3]) numSelect = 4 array_select = util.select_best(array, select, numSelect, highest=True) assert array_select[0] == 6 assert array_select[3] == 1 array_select = util.select_best(array, select, numSelect, highest=False) assert array_select[0] == 3 assert array_select[3] == 4 array_select = util.select_best(array, select, num_select=10, highest=False) assert len(array_select) == len(array)