Skip to content

init_columns no longer flags column names with the same prefix as duplicates - #1155

Open
PieterjanRobbe wants to merge 1 commit into
materialsproject:mainfrom
PieterjanRobbe:fix/contribs-init-columns-prefix
Open

PieterjanRobbe wants to merge 1 commit into
materialsproject:mainfrom
PieterjanRobbe:fix/contribs-init-columns-prefix

Conversation

@PieterjanRobbe

Copy link
Copy Markdown

ContribsClient.init_columns currently rejects two columns when one name is a prefix of the other, for example:

from types import SimpleNamespace
from mp_api.client.contribs.client import ContribsClient

ContribsClient.init_columns(SimpleNamespace(project="demo"), {"a.atomLossFrac": "", "a.atomLoss": None})
# MPContribsClientError: Duplicate definition of a.atomLoss in a.atomLossFrac!

If we match on the column name + . separator instead, we fix the prefix issue and duplicate column names are still rejected.

…duplicates

The duplicate check used col.startswith(k), so a column like a.b was
rejected when a sibling a.bc had already been scanned. Match on the '.'
separator instead; true duplicates (ancestor after child) still raise.

This branch has not been deployed

No deployments
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.

1 participant