-
-
Notifications
You must be signed in to change notification settings - Fork 366
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
first_n, last_n, max_n and min_n reductions #1184
first_n, last_n, max_n and min_n reductions #1184
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1184 +/- ##
==========================================
+ Coverage 85.39% 85.48% +0.09%
==========================================
Files 35 35
Lines 8023 8232 +209
==========================================
+ Hits 6851 7037 +186
- Misses 1172 1195 +23
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
After discussion, we've decided to allow multiple |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Just need user docs, which can be a separate PR.
This is further work on improved inspection reductions (issue #1126) to add
first_n
,last_n
,max_n
andmin_n
reductions. Each accepts a column name and value forn
, the number of results to return for each pixel. For example,max("value", n=3)
will return a DataArray of shape(ny, nx, n)
containing the 3 highest values of column"value"
for each pixel.Demo code using these within a
where
reduction to return corresponding row indexes or values from a different column:which outputs
where, as usual,
-1
means no row index andnan
means no data to return.This allows us to do some complicated combinations such as
to return
count
plusmin_n
andmax_n
(orfirst_n
andlast_n
) in a single datashader pass.max_n
andmin_n
work with dask but not CUDA (issue #1177 needs to be solved for that).first_n
andlast_n
only work on the CPU and without dask, the same asfirst
andlast
(#1177 and #1182 are needed to fix that).Using antialiased lines the results looked OK in some situation and not others, so I am raising a
NotImplemented
error for all of these when using with antialiasing and I will separately consider what is reasonable behaviour here. This includeswhere(first_n)
and so on as well.There is one issue here that needs deciding. I've called the third dimension of the DataArray returned by such a reduction
"n"
to fit in with the namesfirst_n
, etc. You can put multiplewhatever_n
reductions in a singlesummary
reduction as shown above. If they have the samen
then it all works out as expected. But we need a policy on labelling the third dimension if thewhatever_n
have differentn
values. We could keep the firstn
asn
, and if subsequentn
values are different call themn1
,n2
, etc?