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

Add Convention.select_indexes() method #146

Merged
merged 5 commits into from
Jul 10, 2024
Merged

Conversation

mx-moth
Copy link
Contributor

@mx-moth mx-moth commented Jul 10, 2024

Adds the methods Convention.selector_for_indexes(), Convention.select_indexes, and Convention.select_points(). These allow for more efficient extraction of multiple points at the same time. These are similar to their singular counterparts, but take lists of indexes or points instead.

This introduces some changes which are backwards incompatible. These incompatibilities are hopefully minor.

  • Convention.selector_for_indexes() is a new required abstract method, while Convention.selector_for_index() now has a default implementation. emsarray-smc will need updating (Add support for emsarray 0.7.0 emsarray-smc#2)
  • The return type of :meth:.Convention.selector_for_index() has been changed from a dict to an :class:xarray.Dataset, but this new value is also designed to be passed directly to :meth:Dataset.isel() <xarray.Dataset.isel>. The output of Convention.selector_for_index() has always been a convention-specific dict whos only purpose was to be passed to Dataset.isel(), now it is a convention-specific dataset whos only purpose is to be passed to Dataset.isel().
  • :meth:.Convention.select_index() and :meth:.Convention.select_indexes() have a new drop_geometry flag which defaults to True. Previously these methods would act as if drop_geometry was False, but this led to convention-dependent results as to which geometry variables were returned. The fragmented geometry variables from different conventions often did not contain enough data to be useful. By dropping geometry the results are more consistent across all conventions and do not contain potentially fragmented geometry information.

Fixes #106

Using both is confusing in public interfaces. 'indexes' was used in
public interfaces, while 'indices' was only used internally or as the
name of positional arguments. I think we can get away with renaming to
'indexes' without a deprecation cycle this way!
This is a breaking change for plugins as it changes the abstract methods
on the Convention class. `Convention.selector_for_indexes()` is a new
required method, and `Convention.selector_for_index()` now has a default
implementation which calls the new method.
@mx-moth mx-moth merged commit 02917cf into main Jul 10, 2024
15 checks passed
@mx-moth mx-moth deleted the feature/select-indexes branch July 10, 2024 06:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Convention.selector_for_indices()
1 participant