2022 (Sourcery refactored)#161
Closed
sourcery-ai[bot] wants to merge 1 commit into
Closed
Conversation
Comment on lines
-24
to
+38
| # visible from Top | ||
| visible_Top = True | ||
| for j in range(0, i[0]): | ||
| if self.__grid[(j, i[1])] >= self.__grid[(i)]: | ||
| visible_Top = False | ||
|
|
||
| # visible from Left | ||
| visible_Left = True | ||
| for j in range(0, i[1]): | ||
| if self.__grid[(i[0], j)] >= self.__grid[(i)]: | ||
| visible_Left = False | ||
|
|
||
| # visible from Bottom | ||
| visible_Bottom = True | ||
| for j in range(i[0] + 1, self.max_h): | ||
| if self.__grid[(j, i[1])] >= self.__grid[(i)]: | ||
| visible_Bottom = False | ||
|
|
||
| # visible from Right | ||
| visible_Right = True | ||
| for j in range(i[1] + 1, self.max_w): | ||
| if self.__grid[(i[0], j)] >= self.__grid[(i)]: | ||
| visible_Right = False | ||
|
|
||
| is_visible = visible_Top or visible_Left or visible_Bottom or visible_Right | ||
| return is_visible | ||
| visible_Top = all( | ||
| self.__grid[(j, i[1])] < self.__grid[(i)] for j in range(i[0]) | ||
| ) | ||
| visible_Left = all( | ||
| self.__grid[(i[0], j)] < self.__grid[(i)] for j in range(i[1]) | ||
| ) | ||
| visible_Bottom = all( | ||
| self.__grid[(j, i[1])] < self.__grid[(i)] | ||
| for j in range(i[0] + 1, self.max_h) | ||
| ) | ||
| visible_Right = all( | ||
| self.__grid[(i[0], j)] < self.__grid[(i)] | ||
| for j in range(i[1] + 1, self.max_w) | ||
| ) | ||
| return visible_Top or visible_Left or visible_Bottom or visible_Right |
Contributor
Author
There was a problem hiding this comment.
Function Day.is_visible refactored with the following changes:
- Use any() instead of for loop [×4] (
use-any) - Replace range(0, x) with range(x) [×2] (
remove-zero-from-range) - Inline variable that is immediately returned (
inline-immediately-returned-variable) - Invert any/all to simplify comparisons [×4] (
invert-any-all)
This removes the following comments ( why? ):
# visible from Left
# visible from Bottom
# visible from Right
# visible from Top
Comment on lines
-88
to
+77
| t = 0 | ||
| for i in self.__grid: | ||
| if self.is_visible(i): | ||
| t += 1 | ||
| return t | ||
| return sum(bool(self.is_visible(i)) for i in self.__grid) |
Contributor
Author
There was a problem hiding this comment.
Function Day._calculate_1 refactored with the following changes:
- Convert for loop into call to sum() (
sum-comprehension) - Inline variable that is immediately returned (
inline-immediately-returned-variable) - Simplify constant sum() call (
simplify-constant-sum)
Codecov ReportBase: 92.15% // Head: 92.09% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## 2022 #161 +/- ##
==========================================
- Coverage 92.15% 92.09% -0.07%
==========================================
Files 55 55
Lines 2066 2049 -17
==========================================
- Hits 1904 1887 -17
Misses 162 162
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
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.
Pull Request #160 refactored by Sourcery.
If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
NOTE: As code is pushed to the original Pull Request, Sourcery will
re-run and update (force-push) this Pull Request with new refactorings as
necessary. If Sourcery finds no refactorings at any point, this Pull Request
will be closed automatically.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Review changes via command line
To manually merge these changes, make sure you're on the
2022branch, then run:Help us improve this pull request!