Skip to content

Align coarsen chunks by default - #6580

Merged
mrocklin merged 6 commits into
dask:masterfrom
dcherian:coarsen-rechunk
Aug 30, 2020
Merged

mrocklin merged 6 commits into
dask:masterfrom
dcherian:coarsen-rechunk

Conversation

@dcherian

Copy link
Copy Markdown
Collaborator

def test_coarsen_with_excess():
x = da.arange(10, chunks=5)
assert_eq(da.coarsen(np.min, x, {0: 3}, trim_excess=True), np.array([0, 5]))
assert_eq(da.coarsen(np.min, x, {0: 5}, trim_excess=True), np.array([0, 5]))

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function tests for the existing behaviour so it had to be changed...

This is a big backwards incompatible change. I do not know how you want to deal with that.


def test_aligned_coarsen_chunks():

from ..routines import aligned_coarsen_chunks as acc

@dcherian dcherian Aug 30, 2020 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as acc avoids bad black formatting in the assert statements below

@mrocklin mrocklin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking this on @dcherian !

This looks good to me. I made a couple of small requests below, but I think that they should be easy to resolve.

Comment thread dask/array/routines.py Resolved
Comment thread dask/array/routines.py Resolved
Comment thread dask/array/routines.py Resolved
@mrocklin
mrocklin merged commit 3b1303f into dask:master Aug 30, 2020
@mrocklin

Copy link
Copy Markdown
Member

Thanks @dcherian !

@dcherian
dcherian deleted the coarsen-rechunk branch August 30, 2020 23:56
@dcherian

Copy link
Copy Markdown
Collaborator Author

You're welcome!

kumarprabhu1988 pushed a commit to kumarprabhu1988/dask that referenced this pull request Oct 29, 2020
@d-v-b

d-v-b commented Jan 28, 2021

Copy link
Copy Markdown
Member

I'm seeing an error in coarsen caused by this PR: specifically, aligned_coarsen_chunks() can return an invalid chunk size:

chunks = (3125,3125) # sums to 6250
aligned_coarsen_chunks(chunks, 16)
# returns (3136, 3120), sums to 6256, will cause exceptions later

I'm still trying to figure out where this creeps in, but maybe @dcherian will find it faster :) In particular, I'm suspicious of / confused by the third branch in this conditional (what is special about 5?):

        if q == 0:
            continue
        elif r == 0:
            newchunks.append(chunk_size)
        elif r >= 5:
            newchunks.append(choose_new_size(multiple, q + 1, left))
        else:
            newchunks.append(choose_new_size(multiple, q, left))

@dcherian

Copy link
Copy Markdown
Collaborator Author

5 is definitely wrong I think it should be multiple // 2

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.

Issue with trim_excess in dask.array.coarsen

3 participants