Update query_by_values instance_vals handling#2774
Conversation
Restrict EntitySet.query_by_values to accept None, pd.Series, or iterable instance values. Reject scalar, string, and DataFrame inputs with clear TypeError messages, and update tests accordingly. Fixes alteryx#1272
|
|
There was a problem hiding this comment.
Pull request overview
This pull request tightens the accepted input types for EntitySet.query_by_values(..., instance_vals=...), narrowing support to None, pd.Series, or general iterables, and adding explicit TypeErrors for scalars, strings, and pd.DataFrame inputs to simplify the API surface and tests.
Changes:
- Updated
query_by_valuesdocstring and_vals_to_series()validation/conversion logic to rejectstr,pd.DataFrame, and non-iterable scalars. - Updated/added unit tests to validate
pd.Seriessupport and verify invalid inputs raiseTypeError. - Removed prior “scalar/DataFrame succeeds” test expectations.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| featuretools/entityset/entityset.py | Updates instance_vals documentation and enforces stricter type handling in _vals_to_series used by query_by_values. |
| featuretools/tests/entityset_tests/test_es.py | Adjusts tests to cover the new accepted/rejected instance_vals types. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| instance_vals (None, pd.Series, or iterable) : | ||
| Instance(s) to match. Values must be provided as a | ||
| ``pd.Series`` or an iterable of instance values. |
| instance_vals may be None, a pd.Series, or an iterable of values. | ||
| This function always returns a Series or None. |
Summary
Restricts
EntitySet.query_by_valuesto acceptNone,pd.Series, or iterable instance values. Scalar, string, and DataFrame inputs now raise a clearTypeError.Motivation
Featuretools only calls
query_by_valueswith apd.Seriesduring normal operation. Removing support for unused input types simplifies the codebase and test suite.Changes
_vals_to_series()to rejectstr,pd.DataFrame, and scalar inputsinstance_valsparameterpd.Seriessupport and rejection of invalid typesTesting
pytest featuretools/tests/entityset_tests/test_es.py -k "query_by"All 12 related tests pass.
Fixes #1272