Skip to content

lookup(): set prefix, synonyms and shortName as MATLAB does - #12

Merged
stevevanhooser merged 1 commit into
mainfrom
claude/pensive-galileo-j24fio
Oct 21, 2026
Merged

stevevanhooser merged 1 commit into
mainfrom
claude/pensive-galileo-j24fio

Conversation

@stevevanhooser

Copy link
Copy Markdown
Contributor

Fixes item 1 of #11. Items 2–4 stay open there.

Summary

MATLAB's ndi.ontology.lookup sets three of its outputs itself, after the provider returns, so every ontology answers the same way. Python left all three to each provider, and the providers disagreed. lookup() now sets them as MATLAB does:

Field Now (as MATLAB) Before
short_name name2variableName(name) (ontology.m:332) OLS-backed providers returned OLS's short_form (CL_0000540); NDIC, NCIm, NCBITaxon, RRID, PubChem, WormBase, EDAM, IAO and schema returned ''
prefix The prefix as typed, trimmed (:295): ndic:8 → ndic, taxonomy:9606 → taxonomy Several providers returned a canonical prefix: NDIC, NCBITaxon, EDAM, …
synonyms Flattened, with empty entries dropped (:316-327) Passed through as the provider returned them

Why it matters

NDI-python's subject tables (ndi/fun/doc_table.py) name treatment columns from lookup(...).short_name, following MATLAB's treatment.m. Before this change, the same dataset got different column names in each language. A CHEBI treatment became CHEBI_15377 in Python but Water in MATLAB. An NDIC treatment got '' from the lookup, so Python fell back to the treatment's own name.

Callers comparing prefix will see the prefix they typed (ndic, taxonomy, format) rather than the canonical one, which is what MATLAB has always returned.

Tests

  • TestLookupSetsMatlabFields (offline) checks five things:
    • an OLS short_form is replaced by name2variableName(name)
    • a blank short_name gets filled in
    • the prefix comes back as typed
    • an alias prefix is kept
    • synonyms are flattened, with empty entries dropped
  • The shared-case runner now also asserts prefix and short_name for every success case.
  • On the old code, 6 of the 7 new unit tests and 2 offline shared cases fail; with the fix all pass.
  • black, ruff and the offline suite pass: 153 passed, 3 skipped.

Generated by Claude Code

…item 1)

MATLAB's ndi.ontology.lookup sets three outputs itself after the provider
returns: prefix as typed (ontology.m:295), synonyms flattened with empties
dropped (:316-327) and shortName = name2variableName(name) (:332). Python
left them to each provider, and they disagreed: OLS-backed providers
returned OLS's short_form ('CL_0000540') as shortName, nine others ''
and several a canonical prefix ('NDIC' for 'ndic:8').

NDI-python names treatment columns in its subject tables from
shortName, so the same dataset got different columns in each language.

The shared-case runner now asserts prefix and shortName too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017iFBFMQmEZaz21d9ZFJbiH
@stevevanhooser
stevevanhooser merged commit 4a1f137 into main Oct 21, 2026
6 checks passed
@stevevanhooser
stevevanhooser deleted the claude/pensive-galileo-j24fio branch October 21, 2026 16:44
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