def test_purge_excess(self): # pylint: disable=protected-access,invalid-name """ Test purge number excess for very very small tolerance """ with self.assertRaises(IndexError): cla = CLA(weight_bounds=(0, 1), calculate_expected_returns="mean") cla.allocate(asset_prices=self.data, solution='cla_turning_points', asset_names=self.data.columns) cla.weights = list(cla.weights.values) cla.weights = cla.weights*100 cla._purge_num_err(tol=1e-18)
def test_flag_true_for_purge_num_err(self): # pylint: disable=protected-access, no-self-use """ Test whether the flag becomes True in the purge num error function """ cla = CLA() cla.weights = [[1]] cla.lower_bounds = [100] cla.upper_bounds = [1] cla.lambdas = [[1]] cla.gammas = [[1]] cla.free_weights = [[1]] cla._purge_num_err(tol=1) assert not cla.weights assert not cla.lambdas assert not cla.gammas