-
Notifications
You must be signed in to change notification settings - Fork 19
Check if Dask is installed #62
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
fc27229
Check if Dask is installed
jacobtomlinson b445c38
Explicity check for None
jacobtomlinson 62f672b
Turn dask_array_type into a tuple to simplify isinstance check
weiji14 133f194
Merge branch 'main' into no-dask
weiji14 f82e829
Add DuckArrayTypes type hint
weiji14 ec25b8f
Import TYPE_CHECKING and Any from typing
weiji14 bdd3be1
Put dask_array_type type hint under if TYPE_CHECKING block
weiji14 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could also set
dask_array_type
to()
,isinstance(variable, ())
always evaluates toFalse
(though to be consistent,dask_array_type
could also be set to a 1-tuple ifdask.array
is available)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure we could do that, but it feels less readable. Particularly for more junior developers.
My preference would be the more clear
is not None
, but happy to defer to folks who are more active here.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this is in a try/except it should be clear that this is a fallback, and I do feel that the check for
None
somewhat diverts the attention from the purpose of the condition, which is to compare types.As for the trick, a comment just before the assignment should help.
(in any case, I'm even less active here)
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't want to go here, but we could also refactor the try/except import to have a
_HAS_DASK
boolean so that mypy doesn't complain. Xref https://adamj.eu/tech/2021/12/29/python-type-hints-optional-imports/Then the check would become:
but I'm happy enough with the
is not None
check for now, and we could refactor to the style above later when there's a mypy CI.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that link appears to be broken, I get a 404
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, was missing an 's' at the end, fixed now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is fine with
mypy
(we're using it inxarray.namedarray
, which is the most thoroughly typed part ofxarray
– at least as far as I can tell):Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
xarray.namedarray
uses tuples, I thinkcupy-xarray
should use it too! The developers in this repo should be fairly competent, so I think we can figure out the syntax. @jacobtomlinson, do you have time to apply this change? Or I can push to this branch also.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might not have time to get back here quickly (getting ready to go on vacation). So if you don't mind pushing here that would probably get things resolved more quickly. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, was travelling for a bit last month too, but finally got around to this again. @keewis, can you check to see if the changes look ok?