Skip to content

Conversation

@edoyango
Copy link
Collaborator

@edoyango edoyango commented Jan 8, 2026

In addition to adding tests, this "fixes" the numpy and dask Select classes so that they do what is said in the doc string. For example,

from pyearthtools.pipeline.operations.dask.select import Select
import dask.array as da

incoming_data = da.zeros((10,5,2))
select = Select([0])
print(select.apply_func(incoming_data).shape)
select = Select([0, None, 0])
print(select.apply_func(incoming_data).shape)

prints

(10, 5, 1)
(10, 5, 1)

instead of the expected (as per the doc string)

(5,2)
(5)

the old numpy Select does the same thing.

I found the logic difficult to follow, so to correct the behaviour, I rewrote the classes to use numpy/dask's native tuple/slice indexing instead.

The xarray select class does the right thing so didn't need changes.

this fixes the implementation of numpy.Select so that
the results match what is stated in the doc string.
This changes the implementation to use indexing with
native slices.
this fixes the implementation of dask.Select so that
the results match what is stated in the doc string.
This changes the implementation to use indexing with
native slices.
@coveralls
Copy link

Pull Request Test Coverage Report for Build 20802458553

Details

  • 107 of 107 (100.0%) changed or added relevant lines in 5 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.6%) to 65.631%

Totals Coverage Status
Change from base Build 20305027296: 0.6%
Covered Lines: 10636
Relevant Lines: 15846

💛 - Coveralls

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.

2 participants