Skip to content

Commit a6c98b4

Browse files
committed
Fix compatibility with Pandas 1.5.0
Pandas 1.5.0 was released earlier this morning and moved an exception class we use. Routine CI caught this backwards-incompatible change affecting our error handling for `augur filter --query …` evaluation. I audited for usage of other exceptions moved in the same upstream change (as noted in the release notes) and found none in Augur. Resolves: <#1049> Related-to: <pandas-dev/pandas#27656>
1 parent 571ef56 commit a6c98b4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

augur/filter.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,12 @@ def apply_filters(metadata, exclude_by, include_by):
863863
)
864864
except Exception as e:
865865
if filter_function.__name__ == 'filter_by_query':
866-
if isinstance(e, pd.core.computation.ops.UndefinedVariableError):
866+
try:
867+
# pandas ≥1.5.0 only
868+
UndefinedVariableError = pd.errors.UndefinedVariableError
869+
except AttributeError:
870+
UndefinedVariableError = pd.core.computation.ops.UndefinedVariableError
871+
if isinstance(e, UndefinedVariableError):
867872
raise AugurError(f"Query contains a column that does not exist in metadata.") from e
868873
raise AugurError(f"Error when applying query. Ensure the syntax is valid per <https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#indexing-query>.") from e
869874
else:

0 commit comments

Comments
 (0)