Skip to content

Fix _get_superclass_str to handle bare dict superclasses#21

Merged
stevevanhooser merged 2 commits intomainfrom
claude/fix-did-python-bug-nDSG3
Mar 25, 2026
Merged

Fix _get_superclass_str to handle bare dict superclasses#21
stevevanhooser merged 2 commits intomainfrom
claude/fix-did-python-bug-nDSG3

Conversation

@stevevanhooser
Copy link
Copy Markdown
Contributor

Summary

  • Fix _get_superclass_str() in doc2sql.py to handle bare dict superclasses that arrive from MATLAB's jsonencode (which unwraps single-element cell arrays into scalars)
  • Normalize bare dicts to single-element lists in both the top-level superclasses and document_class.superclasses code paths
  • Add regression tests covering bare dict, list, empty, and missing superclass cases

Problem

Documents with a single superclass (e.g. base) had their superclasses field encoded as a bare dict instead of a list by MATLAB's jsonencode. The existing code only checked for list types, so these documents got an empty meta.superclass string, causing isa() queries to miss them entirely. In one test dataset, 98 out of 7,221 documents were affected.

Test plan

  • All 6 new tests in tests/test_doc2sql_superclass.py pass
  • Verify with a real dataset containing MATLAB-encoded single-superclass documents

Fixes: Waltham-Data-Science/NDI-python#52

https://claude.ai/code/session_01W4C2GYKchUodXEVKnnM66T

claude added 2 commits March 25, 2026 16:49
MATLAB's jsonencode unwraps single-element cell arrays into scalar
values, so documents with a single superclass arrive as a bare dict
instead of a list. This caused _get_superclass_str to return an empty
string, breaking isa() queries for those documents.

Normalize bare dict superclasses to single-element lists before
processing, in both the top-level and document_class code paths.

Fixes: Waltham-Data-Science/NDI-python#52

https://claude.ai/code/session_01W4C2GYKchUodXEVKnnM66T
@stevevanhooser stevevanhooser merged commit e871ffa into main Mar 25, 2026
5 checks passed
@stevevanhooser stevevanhooser deleted the claude/fix-did-python-bug-nDSG3 branch March 25, 2026 16:57
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.

DID-python: _get_superclass_str should handle bare dict superclasses

2 participants