src/tests/catwalk_tests/test_evaluation.py

Summary

Maintainability
D
1 day
Test Coverage

File test_evaluation.py has 739 lines of code (exceeds 400 allowed). Consider refactoring.
Open

from triage.component.catwalk.evaluation import (
    SORT_TRIALS,
    ModelEvaluator,
    generate_binary_at_x,
    query_subset_table,
Severity: Major
Found in src/tests/catwalk_tests/test_evaluation.py - About 1 day to fix

    Function test_ModelEvaluator_needs_evaluation_no_bias_audit has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def test_ModelEvaluator_needs_evaluation_no_bias_audit(db_engine_with_results_schema):
        # TEST SETUP:
    
        # create two models: one that has zero evaluations,
        # one that has an evaluation for precision@100_abs
    Severity: Minor
    Found in src/tests/catwalk_tests/test_evaluation.py - About 2 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function test_all_same_labels has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def test_all_same_labels(db_engine_with_results_schema):
        num_entities = 5
        trained_model, model_id = fake_trained_model(
            db_engine_with_results_schema,
            train_end_time=TRAIN_END_TIME,
    Severity: Minor
    Found in src/tests/catwalk_tests/test_evaluation.py - About 35 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function test_model_scoring_inspections has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def test_model_scoring_inspections(db_engine_with_results_schema):
        testing_metric_groups = [
            {
                "metrics": ["precision@", "recall@", "fpr@"],
                "thresholds": {"percentiles": [50.0], "top_n": [3]},
    Severity: Minor
    Found in src/tests/catwalk_tests/test_evaluation.py - About 25 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Line too long (98 > 88 characters)
    Open

        # this all assumes that evaluations are populated. those tests are in the 'no_bias_audit' test

    Limit all lines to a maximum of 79 characters.

    There are still many devices around that are limited to 80 character
    lines; plus, limiting windows to 80 characters makes it possible to
    have several windows side-by-side.  The default wrapping on such
    devices looks ugly.  Therefore, please limit all lines to a maximum
    of 79 characters. For flowing long blocks of text (docstrings or
    comments), limiting the length to 72 characters is recommended.
    
    Reports error E501.

    Line too long (90 > 88 characters)
    Open

                # "as_of_date": fake_test_matrix_store.design_matrix.index.levels[1].tolist(),

    Limit all lines to a maximum of 79 characters.

    There are still many devices around that are limited to 80 character
    lines; plus, limiting windows to 80 characters makes it possible to
    have several windows side-by-side.  The default wrapping on such
    devices looks ugly.  Therefore, please limit all lines to a maximum
    of 79 characters. For flowing long blocks of text (docstrings or
    comments), limiting the length to 72 characters is recommended.
    
    Reports error E501.

    Line too long (93 > 88 characters)
    Open

        # Test that if a protected_df is passed (along with bias config, the only real needed one

    Limit all lines to a maximum of 79 characters.

    There are still many devices around that are limited to 80 character
    lines; plus, limiting windows to 80 characters makes it possible to
    have several windows side-by-side.  The default wrapping on such
    devices looks ugly.  Therefore, please limit all lines to a maximum
    of 79 characters. For flowing long blocks of text (docstrings or
    comments), limiting the length to 72 characters is recommended.
    
    Reports error E501.

    Line too long (93 > 88 characters)
    Open

        # Test that if a protected_df is passed (along with bias config, the only real needed one

    Limit all lines to a maximum of 79 characters.

    There are still many devices around that are limited to 80 character
    lines; plus, limiting windows to 80 characters makes it possible to
    have several windows side-by-side.  The default wrapping on such
    devices looks ugly.  Therefore, please limit all lines to a maximum
    of 79 characters. For flowing long blocks of text (docstrings or
    comments), limiting the length to 72 characters is recommended.
    
    Reports error E501.

    Line too long (89 > 88 characters)
    Open

                # "entity_id": fake_test_matrix_store.design_matrix.index.levels[0].tolist(),

    Limit all lines to a maximum of 79 characters.

    There are still many devices around that are limited to 80 character
    lines; plus, limiting windows to 80 characters makes it possible to
    have several windows side-by-side.  The default wrapping on such
    devices looks ugly.  Therefore, please limit all lines to a maximum
    of 79 characters. For flowing long blocks of text (docstrings or
    comments), limiting the length to 72 characters is recommended.
    
    Reports error E501.

    There are no issues that match your filters.

    Category
    Status