Skip to content

fix(xbrl): de-duplicate enumeration facts without their whitespace (#1760) - #2039

Merged
dgunning merged 1 commit into
mainfrom
fix/1760-enum-set-whitespace
Nov 23, 2026
Merged

dgunning merged 1 commit into
mainfrom
fix/1760-enum-set-whitespace

Conversation

@dgunning

Copy link
Copy Markdown
Owner

What this changes

An extensible-enumeration value is an xs:token list of members. Whitespace between members isn't significant (Extensible Enumerations 2.0 §6.2.2), and duplicate detection compares the collapsed value (§6.2.3). The facts frame compared the raw value, so one member set filed once with a space and once with a line break stayed as two rows.

How it works now:

  • FactsView.get_facts() sets a hidden dedup_value, the whitespace-collapsed value, on enumeration-typed facts only.
  • Duplicate removal compares it in place of value.
  • It's in _DEDUP_OPTIONAL, so the narrowed query().to_dataframe(*columns) path keeps it long enough.
  • It's in _SKIP_COLUMNS, so it isn't a default frame column.

value is never rewritten. The kept row is the first occurrence exactly as filed, which preserves the "raw values as reported" contract in the API guide and follows the approach the issue proposed. Plain strings still compare with their whitespace, because xs:string preserves it. For comparing members across the XBRL and inline paths, XBRL.enumeration_members(value) from #1255 already splits on any whitespace.

Fixes #1760

Verification

  • Ground truth: the Cracker Barrel 10-K the issue cites (accession 0001104659-26-110772) still has three facts for three fiscal years ending 2024-08-02, 2025-08-01 and 2026-07-31. Each names IL, KY, TN and TX, and each value keeps its filed line breaks. This is the network test test_cracker_barrel_state_sets_keep_their_three_periods.

  • Regression test: tests/issues/regression/test_issue_1760.py has 5 offline tests:

    • one member set with different whitespace collapses to one row, keeping the first as filed, in both orders;
    • different member sets stay as two rows;
    • a plain xs:string with different whitespace stays as two rows;
    • the narrowed-column path removes the same duplicate;
    • dedup_value is not a default column.

    The two duplicate tests fail on main's facts.py.

  • No real data changes: row counts for all 47 bundled XBRL fixture filings (94,996 facts) are identical on main and with this change. 48,590 fast XBRL and regression tests pass.

  • Changelog: changelog.d/1760.fixed.md

AI assistance

  • Assisted. Tool and model: Claude Code, Claude Opus 5.5

🤖 Generated with Claude Code

…1760)

An extensible-enumeration value is an xs:token list of members, so the
whitespace between members is not significant (Extensible Enumerations
2.0 section 6.2.2) and duplicate detection compares the collapsed value
(section 6.2.3). `_deduplicate_facts` compared the raw `value`, so one
member set filed once with a space and once with a line break stayed as
two rows.

FactsView.get_facts() now sets a hidden `dedup_value` (the collapsed
value) on enumeration-typed facts only, matched on the local type name
whatever prefix the schema binds to enum2. De-duplication compares it in
place of `value`; it is listed in _DEDUP_OPTIONAL so the early projection
keeps it, and in _SKIP_COLUMNS so it is not a frame column. `value` is
never rewritten: the kept row is the first occurrence as filed, which
keeps the "raw values as reported" contract and follows the issue's
proposal. Plain strings keep comparing with their whitespace, since
xs:string preserves it. The structured member comparison #1760 asked for
across paths already exists as XBRL.enumeration_members() (#1255).

Cracker Barrel's 10-K (0001104659-26-110772) keeps its three periods,
each naming IL, KY, TN and TX, with the filed line breaks. Row counts of
all 47 bundled XBRL fixtures (94,996 facts) are identical before and
after.

Fixes #1760

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dgunning
dgunning merged commit 59773d1 into main Nov 23, 2026
13 checks passed
@dgunning
dgunning deleted the fix/1760-enum-set-whitespace branch November 23, 2026 17:43
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.

Set-valued enumeration facts keep filed line breaks, so the XBRL and inline paths return different strings and duplicate removal misses them

1 participant