def test_differs_for_not_simular_distributions( features_prediction_beta: torch.Tensor, features_target_normal: torch.Tensor) -> None: metric = GS(sample_size=1000, num_iters=100, i_max=1000, num_workers=4) diff = metric(features_prediction_beta, features_target_normal) assert diff >= 5.0, \ f'For different distributions GS diff should be big, got {diff}'
def test_differs_for_not_simular_distributions(features_x_beta, features_y_normal) -> None: prepare_test() metric = GS(sample_size=1000, num_iters=100, i_max=1000, num_workers=4) diff = metric(features_x_beta, features_y_normal) assert diff >= 5.0, \ f'For different distributions GS diff should be big, got {diff}'
def test_similar_for_same_distribution( features_target_normal: torch.Tensor, features_prediction_normal: torch.Tensor) -> None: metric = GS(sample_size=1000, num_iters=100, i_max=1000, num_workers=4) diff = metric(features_prediction_normal, features_target_normal) assert diff <= 2.0, \ f'For same distributions GS should be small, got {diff}'
def test_similar_for_same_distribution(features_y_normal, features_x_normal) -> None: prepare_test() metric = GS(sample_size=1000, num_iters=100, i_max=1000, num_workers=4) diff = metric(features_x_normal, features_y_normal) assert diff <= 2.0, \ f'For same distributions GS should be small, got {diff}'
def test_forward( features_target_normal: torch.Tensor, features_prediction_normal: torch.Tensor, ) -> None: try: metric = GS(num_iters=10, sample_size=8) metric(features_target_normal, features_prediction_normal) except Exception as e: pytest.fail(f"Unexpected error occurred: {e}")
def test_initialization() -> None: try: GS() except Exception as e: pytest.fail(f"Unexpected error occurred: {e}")
def test_fails_if_libs_not_installed(features_y_normal, features_x_normal) -> None: with pytest.raises(ImportError): metric = GS(num_iters=10, sample_size=8) metric(features_y_normal, features_x_normal)
def test_forward(features_y_normal, features_x_normal,) -> None: try: metric = GS(num_iters=10, sample_size=8) metric(features_y_normal, features_x_normal) except Exception as e: pytest.fail(f"Unexpected error occurred: {e}")