-
-
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
Code cleanup #5234
Code cleanup #5234
Conversation
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.
Nice! Thanks @andersy005
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.
Thanks @andersy005 - I am not so sure about the inline dicts: once they begin to span more than 2 lines I find them more difficult than helpful.
else: | ||
extend = "neither" | ||
return extend | ||
return "neither" |
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 don't like the pattern so much but you could remove the else
).
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.
thanks, @andersy005.
The multiline dict comprehensions are a matter of taste (I do prefer them over item assignment in a loop where possible), but as far as I can tell the only difference is the speed of the loop evaluation in CPython (dict comprehensions iterate in C)
xarray/core/coordinates.py
Outdated
level_list = [] | ||
names = [] | ||
|
||
for i, index in enumerate(indexes): |
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 i
is only used once, you could also use zip(indexes, repeat_counts)
instead of enumerate(...)
Co-authored-by: keewis <keewis@users.noreply.github.com> Co-authored-by: Mathias Hauser <mathause@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Stephan Hoyer <shoyer@google.com>
I feel this PR is too big and diverse to accept it as a whole. For example I like most changes from older style formatting to f-strings, but I disagree strongly the moving the |
While I don't have the same sense on the specifics, if people feel strongly then it may be reasonable to revert or pause on some of these. What do you suggest re the broader PR though? While focused PRs are easier to review and reach agreement — now this is here, it does seem on net beneficial, and we should take advantage of the benefit. Are there a few items you feel strongly about that we could revert and then merge the rest? |
@max-sixty & @andersy005 mine was more of a general comment. It is OK to merge it for me, but please after the release! |
If folks are in favor of the original style (inline variables that are immediately returned) throughout the codebase, I'm happy to revert back to the original style :) |
@andersy005 thanks for your hard work here. On the whole, I think this will be a net benefit to the codebase, but in my review I pointed out a number of locations where I did not find the style to be improved (in my opinion). There is also one place where I think your logic may have an error. It would be nice to come up with a policy around "style clean-up" PRs for the future. In general, I think these are not a good idea, for several reasons:
Instead, I would suggest a policy of a selective cleanup only. Feel free to clean-up style when it arises in the process of normal coding, e.g., when you are modifying nearly or related code for another reason. This reduces the risk of introducing inadvertent errors, and the fact that you were working on nearby code means that this part of the codebase is worthy of improvement. Code-base wide clean-up for particular issues may be warranted occasionally, but I would suggest always discussing it with other core developers first. |
@shoyer, Thank you for the thorough feedback.
👍🏽. I reverted back to the original style in most places. There're a few comments that I haven't addressed yet. I will look into those sometime this weekend.
I agree. I didn't expect the PR to get this large. My original intent when I created the PR was to clean the backends code, and I ended up invading other areas :(. In the future, I'll definitely make sure to start a discussion before working on changes that may end up affecting a large chunk of the code base. |
This is going to collect merge conflicts — shall we merge? |
@max-sixty, I'm going to address a few issues pointed out during the review, then we can merge afterwards. |
Shall we also add parts of Stephan's comment to the "Contributing Guide" in the documentation? |
👍🏽 for addressing this in a separate PR |
I believe I have addressed most, if not all changes requested during the review. If there are still disputable changes that need addressing, please let me know |
Looks like this is done. Thanks @andersy005 |
* upstream/master: combine keep_attrs and combine_attrs in apply_ufunc (pydata#5041) Explained what a deprecation cycle is (pydata#5289) Code cleanup (pydata#5234) FacetGrid docstrings (pydata#5293) Add whats new for dataset interpolation with non-numerics (pydata#5297) Allow dataset interpolation with different datatypes (pydata#5008) Flexible indexes: add Index base class and xindexes properties (pydata#5102) pre-commit: autoupdate hook versions (pydata#5280) convert the examples for apply_ufunc to doctest (pydata#5279) fix the new whatsnew section Ensure `HighLevelGraph` layers are `Layer` instances (pydata#5271)
* upstream/master: (23 commits) combine keep_attrs and combine_attrs in apply_ufunc (pydata#5041) Explained what a deprecation cycle is (pydata#5289) Code cleanup (pydata#5234) FacetGrid docstrings (pydata#5293) Add whats new for dataset interpolation with non-numerics (pydata#5297) Allow dataset interpolation with different datatypes (pydata#5008) Flexible indexes: add Index base class and xindexes properties (pydata#5102) pre-commit: autoupdate hook versions (pydata#5280) convert the examples for apply_ufunc to doctest (pydata#5279) fix the new whatsnew section Ensure `HighLevelGraph` layers are `Layer` instances (pydata#5271) New whatsnew section Release-workflow: Bug fix (pydata#5273) more maintenance on whats-new.rst (pydata#5272) v0.18.0 release highlights (pydata#5266) Fix exception when display_expand_data=False for file-backed array. (pydata#5235) Warn ignored keep attrs (pydata#5265) Disable workflows on forks (pydata#5267) fix the built wheel test (pydata#5270) pypi upload workflow maintenance (pydata#5269) ...
…e_units * upstream/master: combine keep_attrs and combine_attrs in apply_ufunc (pydata#5041) Explained what a deprecation cycle is (pydata#5289) Code cleanup (pydata#5234) FacetGrid docstrings (pydata#5293) Add whats new for dataset interpolation with non-numerics (pydata#5297) Allow dataset interpolation with different datatypes (pydata#5008) Flexible indexes: add Index base class and xindexes properties (pydata#5102)
* upstream/master: Update release guide (pydata#5274) combine keep_attrs and combine_attrs in apply_ufunc (pydata#5041) Explained what a deprecation cycle is (pydata#5289) Code cleanup (pydata#5234) FacetGrid docstrings (pydata#5293) Add whats new for dataset interpolation with non-numerics (pydata#5297) Allow dataset interpolation with different datatypes (pydata#5008)
Thanks @andersy005 ! |
This PR introduces small changes to enhance code maintainability...
pre-commit run --all-files