-
Notifications
You must be signed in to change notification settings - Fork 17
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
order: clarify ordering of ties #409
Comments
we currently use this implementation from the legacy openeo-processes-python repo: https://github.com/Open-EO/openeo-processes-python/blob/f57c663e8708061a8222851a8aec2762ac46b0bb/src/openeo_processes/arrays.py#L745-L817 which behaves like the current spec if I understand correctly: import numpy as np
data = np.array([1, 2, 2, 3])
print(data)
# ---> [1 2 2 3]
# Ascending
print(numpy.argsort(data, kind="mergesort"))
# ---> [0 1 2 3]
# Descending
print(numpy.argsort(-data, kind="mergesort"))
# ---> [3 1 2 0] |
maybe I'm misunderstanding, but if you mean flipping the sign of the input data with "flipping the array", I think the descending mode works just fine with |
Apologies, typo in my description: Flipping the sign only works on numerical arrays, but will fail on string/datetime arrays. |
If it works with argsort in the old implementation, why do we need a change here? Can you give some examples, @LukeWeidenwalker? |
Adding the minus-sign like in the old implementation only works on numerical arrays: You cannot do this on e.g. string arrays, it will error out. For those other arrays, you can still get the sorting indices with Depending on your answer to this comment: Other than changing this in the spec, we can of course just not support anything other than numerical arrays in our |
Order allows Alternatively, just remove the strings from the schema (or whatever you don't support). This is reasonable, I think. |
In our backend we only support number, null or a valid ISO date string as inputs. We then use the javascript sort function which handles ties as described in the process documentation (= Stefaan's example). |
No, just tried again, this doesn't work!
@soxofaan so how does your process handle datetime strings then? |
with strings we don't do date interpretation, but that's usually not a problem with ISO8601 A string array is eventually passed to
A mixed array (strings and numbers) also fails in ascending mode with:
I don't think we ever had someone complaining about this and requiring proper string support for the |
It seems it's hard to really come to a conclusion here with the variability of implementations.
The simpliest part would probably be 5, but this would probably lead to a change in SH, right?
@soxofaan fyi: The spec says: "Temporal strings can not be compared based on their string representation due to the time zone/time-offset representations." |
yes I know, I just mean that is practically not a problem in VITO backend because we usually only work at date resolution (and if there is a time component we'd always use UTC) |
Proposal: |
Changed in dcd3b8a |
Process ID: order
Describe the issue:
The simplest implementation to support the
asc
parameter is to simply flip the input array before running argsort if descending order is desired. However, theorder
process currently requires thatTies will be left in their original ordering
, regardless of whetherasc=True
orasc=False
. This means that we cannot simply flip theinput arrayarray with the ordered indices, because ties would be flipped too. This makes the implementation more unwieldy than it has to be.Proposed solution:
Change this requirement such that ties will be in the original ordering if asc=True and flipped otherwise.
Additional context:
See here for initial discussion
The text was updated successfully, but these errors were encountered: