Merged
Conversation
Member
|
Nice minimal fix 👍 |
jrbourbeau
reviewed
Jul 1, 2021
Member
jrbourbeau
left a comment
There was a problem hiding this comment.
Thanks @ncclementi! Overall this looks great. Passing user-provided chunks through normalize_chunks is definitely the way to go.
Fortunately normalize_chunks has some of the same chunksize calculation logic that we've implemented here in da.eye. So since we're now always calling normalize_chunks, we can remove some code from da.eye which is now unnecessary:
diff --git a/dask/array/creation.py b/dask/array/creation.py
index 2e8b0eab..87cc715b 100644
--- a/dask/array/creation.py
+++ b/dask/array/creation.py
@@ -544,18 +544,12 @@ def eye(N, chunks="auto", M=None, k=0, dtype=float):
if not isinstance(chunks, (int, str)):
raise ValueError("chunks must be an int or string")
- chunks = normalize_chunks(chunks, shape=(N, M), dtype=dtype)
- chunks = chunks[0][0]
+ vchunks, hchunks = normalize_chunks(chunks, shape=(N, M), dtype=dtype)
+ chunks = vchunks[0]
+
token = tokenize(N, chunks, M, k, dtype)
name_eye = "eye-" + token
- vchunks = [chunks] * (N // chunks)
- if N % chunks != 0:
- vchunks.append(N % chunks)
- hchunks = [chunks] * (M // chunks)
- if M % chunks != 0:
- hchunks.append(M % chunks)
-
for i, vchunk in enumerate(vchunks):
for j, hchunk in enumerate(hchunks):
if (j - i - 1) * chunks <= k <= (j - i + 1) * chunks:
jrbourbeau
approved these changes
Jul 2, 2021
Member
jrbourbeau
left a comment
There was a problem hiding this comment.
Thanks @ncclementi! Will merge after CI finishes up
Member
|
Hmm there's an unrelated daily stock test failure (which I'm able to reproduce locally). Given that the error message says I'll wait a bit and see if the test passes then |
Member
|
Just merged |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
eyekey error #7852black dask/flake8 dask/isort daskFixes bug in
da.eyecase of chunks=-1.