Repository navigation
Conversation
invalid_param_error sorted the valid values and _validate_feature_overrides sorted the unknown keys for the message. With mixed int/str column labels, which PreTab supports, sorted() raised a TypeError, so a misspelled feature_preprocessing key or FeatureGroup source surfaced as an unrelated error instead of the actionable InvalidParamError. A new _sorted_for_display helper sorts normally and falls back to the string form for values that cannot be compared. Both message paths use it. Fixes #169
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #169.
With mixed int/str column labels, a
feature_preprocessingkey orFeatureGroupsource that names a missing column raisedTypeError: '<' not supported between instances of 'int' and 'str'instead of the actionableInvalidParamError.Root cause
The message builders sorted labels that are not mutually comparable:
invalid_param_error(pretab/exceptions.py) calledsorted(valid), and both the override check andvalidate_feature_groupspass the frame's columns asvalid;Preprocessor._validate_feature_overridesalso calledsorted(unknown_features).Fix
_sorted_for_displayinpretab/exceptions.py: it returnssorted(values), or, when that raisesTypeError, the values ordered by their string form (with the type name as a tie-breaker).invalid_param_erroruses it for the valid values, and_validate_feature_overridesuses it for the unknown keys.[1, 2, 10], so existing messages are unchanged.Behaviour changes
InvalidParamErrorlisting e.g.Valid values: [0, 1, 'age']. Before, it raisedTypeError.Documentation
invalid_param_errordocstring: how incomparable valid values are listed.Tests
tests/integration/test_exceptions.py::test_invalid_param_error_lists_mixed_type_valid_values: fails onmain, passes here.tests/integration/test_exceptions.py::test_invalid_param_error_keeps_the_natural_order_of_comparable_values: guard that passes on both.tests/integration/test_column_labels.py::test_unknown_column_with_mixed_labels_raises_invalid_param_error(override, two overrides, group source): fails onmain, passes here.Reproduction
The script from #169 on this branch:
Checks
just test: 4681 passed, 59 skipped, 7 xfailed; coverage 95.71% (gate 90%).scripts/quickstart.pypasses.just docs: strict build succeeds.just check: all pre-commit and pre-push hooks pass (file hygiene, ruff format, ruff lint, prettier, pyright with 0 errors).pretab.exceptions, the shared leaf module; no import direction changes.Merge notes
main.pretab.exceptionsimport block ofpretab/preprocessor.py(it addsEmptyDataError); Git merges the two cleanly, and this branch merges cleanly with the other open per-issue branches (fix(binning): reject edges the soft encoding cannot use #150 to fix(transformers): return feature names as an object array #168).