Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[0.2.dev7] MergedChoiceTable check for duplicate column names #54

Merged
merged 2 commits into from
Dec 12, 2018

Conversation

smmaurer
Copy link
Member

This PR adds a check to the MergedChoiceTable constructor to make sure there aren't any column names that overlap between the observations and alternatives tables.

It's ok for the chosen_alternatives column of the observations table to have the same name as the index of the alternatives table, though.

Discussion

This aligns ChoiceModels with the strategy for overlapping column names discussed in UrbanSim Templates issue #67.

Other changes

All the existing unit tests pass, and I wrote some new ones to test permutations of overlapping column names.

Versioning

  • updates the version number to 0.2.dev7

@smmaurer smmaurer requested a review from mxndrwgrdnr December 11, 2018 23:07
@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 75.189% when pulling d98e956 on column-name-safety into 5915217 on master.

Copy link
Member

@mxndrwgrdnr mxndrwgrdnr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@smmaurer smmaurer merged commit 769800d into master Dec 12, 2018
@smmaurer smmaurer deleted the column-name-safety branch December 12, 2018 17:54
# Check for duplicate column names
obs_cols = list(observations.columns) + list(observations.index.names)
alt_cols = list(alternatives.columns) + list(alternatives.index.names)
dupes = [c for c in obs_cols if c in alt_cols]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this using lists (O(a*o)) instead of sets (O(min(a,o)))? like:

        obs_cols = set(observations.columns) + set(observations.index.names)
        alt_cols = set(alternatives.columns) + set(alternatives.index.names)
        dupes = obs_cols & in alt_cols

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Eh2406 Thanks, that's definitely better! Unfortunately i just merged this PR, but i'll update this in the next one

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

4 participants