def test__rebuild_correlation_matrix_outside(self): """Test ``_rebuild_correlation_matrix`` with an invalid correlation input. If the input contains values outside -1 and 1, the method is expected to scale them down to the valid range. Input: - list of lists with values outside of -1 and 1 Expected Output: - numpy array with the square correlation matrix """ # Run triangular_covariance = [ [1.0], [2.0, 1.0] ] correlation = GaussianCopula._rebuild_correlation_matrix(triangular_covariance) # Assert expected = [ [1.0, 0.5, 1.0], [0.5, 1.0, 0.5], [1.0, 0.5, 1.0] ] assert expected == correlation
def test__rebuild_correlation_matrix_valid(self): """Test ``_rebuild_correlation_matrix`` with a valid correlation input. If the input contains values between -1 and 1, the method is expected to simply rebuild the square matrix with the same values. Input: - list of lists with values between -1 and 1 Expected Output: - numpy array with the square correlation matrix """ # Run triangular_covariance = [ [0.1], [0.2, 0.3] ] correlation = GaussianCopula._rebuild_correlation_matrix(triangular_covariance) # Assert expected = [ [1.0, 0.1, 0.2], [0.1, 1.0, 0.3], [0.2, 0.3, 1.0] ] assert expected == correlation