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

Suppressed performance warning for many small chunks in reorder(...) #79

Merged
merged 4 commits into from
Jun 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion stmtools/stm.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""space-time matrix module."""

import logging
import warnings
from collections.abc import Iterable
from pathlib import Path

Expand Down Expand Up @@ -392,6 +393,9 @@ def reorder(self, xlabel="azimuth", ylabel="range", xscale=1.0, yscale=1.0):
resolution of the ordering: only the whole-number part influences the order.
While coordinates could also be offset, this has limited effect on the relative order.

Also note that reordering a dataset may be an expensive operation. Because it is applied
lazily, this preformance cost will only manifest once the elements are evaluated.

Parameters
----------
self : SpaceTimeMatrix
Expand All @@ -416,7 +420,14 @@ def reorder(self, xlabel="azimuth", ylabel="range", xscale=1.0, yscale=1.0):
"space": self._obj.chunksizes["space"][0],
"time": self._obj.chunksizes["time"][0],
}
self._obj = self._obj.sortby(self._obj.order)
with warnings.catch_warnings():
# Trying to supporess only
# [...]/lib/python3.12/site-packages/xarray/core/indexing.py:1620: PerformanceWarning:
# Slicing with an out-of-order index is generating [...] times more chunks
# but unable to find the warning category.
#warnings.simplefilter(action="ignore", category=pd.errors.PerformanceWarning)
warnings.simplefilter(action="ignore")
self._obj = self._obj.sortby(self._obj.order)
self._obj = self._obj.chunk(chunks)

return self._obj
Expand Down
Loading