Skip to content

parse_reference skips rows with a non-numeric share, but no test shows it or compares it with the web engine #1002

Closed

Description

@yakew7

Where: faircode/profiler.py parse_reference() (the except (TypeError, ValueError): continue, lines 541-542), assets/profiler-engine.js parseReference(), tests/test_profiler.py, tests/test_js_parity_profile_thresholds.py.

Current gap: a reference row whose share cannot be read (n/a, an empty cell, ?) is dropped without a message, and the remaining shares are used as they are. Coverage shows the branch never runs. Neither the silent skip nor the question of whether the web engine drops the same rows (and keeps the same per-column scale decision) is tested, so a baseline with one bad cell could change which columns count as percentages in one engine only.

Repro:

>>> import pandas as pd; from faircode.profiler import parse_reference
>>> parse_reference(pd.DataFrame({"column": ["sex"] * 3, "group": ["M", "F", "X"], "share": [0.5, "n/a", 0.5]}))
{'sex': {'M': 0.5, 'X': 0.5}}      # the F row vanished with no note

Suggested approach: add the case to the Python tests and to the existing parseReference parity test, and decide whether a skipped row should add a note to the result (the CLI already prints notes for similar drops).

Activity

  1. yakew7 commented on Oct 16, 2026

    @yakew7
    OwnerAuthor

    Fixed in c4be74f (on main). Full suite green (941 passed).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions