def test_transform_dimensions_gt_two(self, mock_asarray): # setup array = MagicMock() array.shape.__len__.return_value = 3 mock_asarray.return_value = array # run with self.assertRaises(ValueError): BaseHyperParam.transform(MagicMock(), 1)
def test_transform_values_list(self): # setup instance = MagicMock() instance._transform.return_value = 2 values = np.array([[1]]) # run result = BaseHyperParam.transform(instance, values) # assert instance._within_hyperparam_space.assert_called_once_with(np.array([[1]])) instance._transform.assert_called_once_with(np.array([[1]])) assert result == 2
def test_transform_values_not_ndarray(self, mock_np_asarray): # setup instance = MagicMock() instance._transform.return_value = 2 mock_np_asarray.return_value = np.array([[1]]) values = 1 # run result = BaseHyperParam.transform(instance, values) # assert mock_np_asarray.asser_called_once_with(1) instance._within_hyperparam_space.assert_called_once_with(np.array([[1]])) instance._transform.assert_called_once_with(np.array([[1]])) self.assertEqual(result, 2)