Skip to content

Commit

Permalink
update use of catch_warnings for backwards compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
sjvenditto committed Nov 7, 2024
1 parent f5f15e4 commit bc506d3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion pynapple/core/time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -1118,8 +1118,9 @@ def __getitem__(self, key, *args, **kwargs):
and all([isinstance(k, str) for k in key])
):
if all(k in self.columns for k in key):
with warnings.catch_warnings(action="ignore"):
with warnings.catch_warnings():
# ignore deprecated warning for loc
warnings.simplefilter("ignore")
return self.loc[key]
else:
return _MetadataMixin.__getitem__(self, key)
Expand Down
3 changes: 2 additions & 1 deletion tests/test_time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -1389,7 +1389,8 @@ def test_deprecation_warning(self, tsdframe):
tsdframe.loc[columns[0]]
if isinstance(columns[0], str):
# suppressed warning with getitem, which implicitly uses loc
with warnings.catch_warnings(action="error"):
with warnings.catch_warnings():
warnings.simplefilter("error")
tsdframe[columns[0]]


Expand Down

0 comments on commit bc506d3

Please sign in to comment.