Conversation
| self.as_set = 1 << self.id | ||
| self.as_set = 1 << self.id | ||
| global _PRP_SET_ALL | ||
| _PRP_SET_ALL |= self.as_set | ||
| self.piece = rot.piece | ||
| self.rotation = rot | ||
| self.piece_id = self.piece.id | ||
| self.name = name | ||
| self.contact = pt | ||
| self.piece = rot.piece | ||
| self.rotation = rot | ||
| self.piece_id = self.piece.id | ||
| self.name = name | ||
| self.contact = pt | ||
| _PIECE_ROTATION_POINTS.append(self) | ||
|
|
||
| dy, dx = pt | ||
|
|
||
| self.tiles: list[Tile] = [] | ||
| self.adjacent: set[Tile] = set() | ||
| self.corners: set[Tile] = set() | ||
|
|
||
| for y, x in rot.tiles: | ||
| self.tiles.append((y - dy, x - dx)) | ||
|
|
||
| self.tiles.extend((y - dy, x - dx) for y, x in rot.tiles) |
There was a problem hiding this comment.
Function _PieceRotationPoint.__init__ refactored with the following changes:
- Replace a for append loop with list extend (
for-append-to-extend)
| def _create_piece(name: str, shape: list[list[int]]) -> Piece: | ||
| def _create_piece(name: str, shape: list[list[int]]) -> Piece: |
There was a problem hiding this comment.
Function _create_piece refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| _PRP_REL_COORDS: set[Tile] = set() | ||
| for _pt in _PRP_WITH_REL_COORD: | ||
| _PRP_REL_COORDS.add(_pt) | ||
| _PRP_REL_COORDS: set[Tile] = set(_PRP_WITH_REL_COORD) |
There was a problem hiding this comment.
Lines 421-423 refactored with the following changes:
- Convert for loop into set comprehension (
set-comprehension) - Replace identity comprehension with call to collection constructor (
identity-comprehension)
| if isinstance(value, Move): | ||
| return self.is_equal(value) | ||
| else: | ||
| return False | ||
| return self.is_equal(value) if isinstance(value, Move) else False |
There was a problem hiding this comment.
Function Move.__eq__ refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp)
| self._state: list[_BoardState] = [] | ||
| self._tiles = np.zeros((20, 20), dtype=np.uint8) | ||
| self._n_players = n_players | ||
| self._state: list[_BoardState] = [] | ||
| self._tiles = np.zeros((20, 20), dtype=np.uint8) | ||
| self._n_players = n_players |
There was a problem hiding this comment.
Function Board.__init__ refactored with the following changes:
- Replace a for append loop with list extend (
for-append-to-extend)
| } | ||
|
|
||
| def __init__(self, name: str="TileWeight", weight_map: str='wall_crawl', custom_weights: list[int | float]=None): | ||
| def __init__(self, name: str="TileWeight", weight_map: str='wall_crawl', custom_weights: list[int | float]=None): |
There was a problem hiding this comment.
Function TileWeightEngine.__init__ refactored with the following changes:
- Swap if/else branches (
swap-if-else-branches) - Merge else clause's nested if statement into elif (
merge-else-if-into-elif) - Lift code into else after jump in control flow (
reintroduce-else)
| def get_matches_by_engine(self, engine: int) -> list[MatchData]: | ||
| filtered_matches = [x for x in self.match_data if engine in x.engines] | ||
| return filtered_matches | ||
| return [x for x in self.match_data if engine in x.engines] |
There was a problem hiding this comment.
Function TournamentResults.get_matches_by_engine refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| if sort_dir != 'asc' and sort_dir != 'desc': | ||
| if sort_dir not in ['asc', 'desc']: |
There was a problem hiding this comment.
Function TournamentResults.get_engine_rankings_display refactored with the following changes:
- Replace multiple comparisons of same variable with
inoperator (merge-comparisons)
| if (len(engines) < 1): | ||
| if not engines: | ||
| raise Exception("Number of engines must be greater than 0") | ||
| if move_seconds <= 0: | ||
| raise Exception("Must allow greater than 0 seconds per move") | ||
|
|
There was a problem hiding this comment.
Function Tournament.__init__ refactored with the following changes:
- Simplify sequence length comparison (
simplify-len-comparison)
|
|
||
| self.move_seconds = move_seconds if move_seconds is not None else self._seconds | ||
| if self.move_seconds <= 0: | ||
| raise Exception("Must allow greater than 0 seconds per move") | ||
|
|
There was a problem hiding this comment.
Function Tournament.play refactored with the following changes:
- Replace identity comprehension with call to collection constructor (
identity-comprehension)
Branch
masterrefactored by Sourcery.If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
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
masterbranch, then run:Help us improve this pull request!