-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Optimize dask array equality checks. #3453
Merged
Merged
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e84cc97
Optimize dask array equality checks.
dcherian 8739ddd
better docstring
dcherian 4a66e7c
review suggestions.
dcherian e99148e
add concat test
dcherian ee0d422
Merge remote-tracking branch 'upstream/master' into fix/dask-computes
dcherian 5e742e4
update whats new
dcherian 53c0f4e
Add identity check to lazy_array_equiv
dcherian 08f7f74
Merge remote-tracking branch 'upstream/master' into fix/dask-computes
dcherian 6e4c11f
Merge branch 'master' into fix/dask-computes
dcherian 4ee2963
pep8
dcherian 0711eb0
bugfix.
dcherian 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 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
|
||
from . import dtypes, pdcompat | ||
from .alignment import deep_align | ||
from .duck_array_ops import lazy_array_equiv | ||
from .utils import Frozen, dict_equiv | ||
from .variable import Variable, as_variable, assert_unique_multiindex_level_names | ||
|
||
|
@@ -123,16 +124,24 @@ def unique_variable( | |
combine_method = "fillna" | ||
|
||
if equals is None: | ||
out = out.compute() | ||
# first check without comparing values i.e. no computes | ||
for var in variables[1:]: | ||
equals = getattr(out, compat)(var) | ||
equals = getattr(out, compat)(var, equiv=lazy_array_equiv) | ||
if not equals: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is right (as above) but the next one is wrong. I've fixed that and added a test. |
||
break | ||
|
||
# now compare values with minimum number of computes | ||
if not equals: | ||
out = out.compute() | ||
for var in variables[1:]: | ||
equals = getattr(out, compat)(var) | ||
if not equals: | ||
break | ||
|
||
if not equals: | ||
raise MergeError( | ||
"conflicting values for variable {!r} on objects to be combined. " | ||
"You can skip this check by specifying compat='override'.".format(name) | ||
f"conflicting values for variable {name!r} on objects to be combined. " | ||
"You can skip this check by specifying compat='override'." | ||
) | ||
|
||
if combine_method: | ||
|
This file contains 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
This file contains 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.
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.
same concern as below -- should this be checking against
None
explicitly, which I believelazy_array_equiv
can return?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 think this is right. We are exiting early because
equals[k] is not True
i.e. either the shapes are not equal, or one (or both) of the arrays is a numpy array or the dask names are not equal