-
Notifications
You must be signed in to change notification settings - Fork 1
2022 (Sourcery refactored) #161
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
Conversation
| # 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 |
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.
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
| 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) |
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.
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. |
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!