Skip to content

Improve coverage for embedding evaluation helpers and fallback branches#1353

Merged
SkBlaz merged 3 commits intomasterfrom
copilot/improve-test-coverage-b1fab358-4fc5-42b0-a0f0-47c15e19dfd4
Apr 23, 2026
Merged

Improve coverage for embedding evaluation helpers and fallback branches#1353
SkBlaz merged 3 commits intomasterfrom
copilot/improve-test-coverage-b1fab358-4fc5-42b0-a0f0-47c15e19dfd4

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 22, 2026

This PR addresses the coverage gap in embedding evaluation utilities by adding focused unit coverage for untested operator paths, empty-input handling, and error/fallback behavior. The goal is to harden py3plex/ml/embedding/evaluation.py against edge-case regressions.

  • Coverage target

    • Added a dedicated test module: tests/test_ml_embedding_evaluation.py.
    • Focuses specifically on branch-heavy helpers in py3plex/ml/embedding/evaluation.py.
  • Operator and feature-construction branches

    • Added explicit tests for edge_operator modes: hadamard, average, weighted_l1, weighted_l2, cosine.
    • Added invalid-operator assertion path.
    • Added empty-edge behavior checks in build_edge_features for both vector and scalar-output operators.
  • Evaluation helper paths

    • Added direct helper coverage for:
      • evaluate_link_prediction
      • evaluate_node_classification
      • evaluate_clustering
    • Extended evaluate_link_prediction_embeddings coverage for both valid classification input and single-class failure behavior.
  • Fallback/error propagation in split logic

    • Added targeted coverage for evaluate_node_classification_report:
      • first split attempt fails, fallback succeeds
      • both attempts fail and propagate the error
split_mock = Mock(
    side_effect=[
        ValueError("forced split failure"),
        (X_train, X_test, y_train, y_test),
    ]
)
monkeypatch.setattr(evaluation, "train_test_split", split_mock)

report = evaluation.evaluate_node_classification_report(
    np.zeros((6, 2), dtype=np.float32),
    [0, 1, 0, 1, 0, 1],
    random_state=0,
)

@SkBlaz SkBlaz marked this pull request as ready for review April 23, 2026 21:02
@SkBlaz SkBlaz self-requested a review as a code owner April 23, 2026 21:02
@SkBlaz SkBlaz merged commit 925f356 into master Apr 23, 2026
53 of 54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants