def test_lambda_for_no_bounded_weights(self): # pylint: disable=protected-access,invalid-name """ Test the computation of lambda when there are no bounded weights """ cla = CLA(weight_bounds=(0, 1), calculate_expected_returns="mean") cla.allocate(asset_prices=self.data, solution='min_volatility', asset_names=self.data.columns) data = self.data.cov() data = data.values x, y = cla._compute_lambda(covar_f_inv=data, covar_fb=data, mean_f=cla.expected_returns, w_b=None, asset_index=1, b_i=[[0], [1]]) assert isinstance(x, float) assert isinstance(y, int)
def test_lambda_for_zero_matrices(self): # pylint: disable=protected-access,invalid-name """ Test the computation of lambda when there are no bounded weights. The method should return None, None """ cla = CLA(weight_bounds=(0, 1), calculate_expected_returns="mean") cla.allocate(asset_prices=self.data, solution='min_volatility', asset_names=self.data.columns) data = self.data.cov() data = data.values data[:, :] = 0 x, y = cla._compute_lambda(covar_f_inv=data, covar_fb=data, mean_f=cla.expected_returns, w_b=None, asset_index=1, b_i=[[0], [1]]) assert not x assert not y