Skip to content
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

Sourcery refactored master branch #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Apr 5, 2020

Branch master refactored 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 master branch, then run:

git fetch origin sourcery/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Comment on lines -109 to +112
copy_ops = []
for self_var, other_var in zip(self.variables, other.variables):
copy_ops.append(tf.assign(other_var, self_var))
return copy_ops
return [
tf.assign(other_var, self_var)
for self_var, other_var in zip(self.variables, other.variables)
]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function BaseNetwork.assign refactored with the following changes:

  • Convert for loop into list comprehension (list-comprehension)
  • Inline variable that is immediately returned (inline-immediately-returned-variable)

average_moves = sum([len(game.moves)
for game in games]) / self.config.batch_size
average_moves = sum(len(game.moves) for game in games) / self.config.batch_size
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function PolicyTraining.process_results refactored with the following changes:

  • Replace unneeded comprehension with generator (comprehension-to-generator)

Comment on lines -266 to +265
if self.result:
self.policy_player_score = float(policy_player_turn)
else:
self.policy_player_score = 0.5
self.policy_player_score = float(policy_player_turn) if self.result else 0.5
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Game.move refactored with the following changes:

  • Replace if statement with if expression (assign-if-exp)

return max([int(run) for run in runs])
return max(int(run) for run in runs)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function run_directory.find_previous_run refactored with the following changes:

  • Replace unneeded comprehension with generator (comprehension-to-generator)

@sourcery-ai
Copy link
Author

sourcery-ai bot commented Aug 19, 2020

Sourcery Code Quality Report (beta)

✅  Merging this PR will increase code quality in the affected files by 0.01 out of 10.

Quality metrics Before After Change
Complexity 1.69 1.64 -0.05 🔵
Method Length 62.95 62.69 -0.26 🔵
Quality 8.47 8.48 0.01 🔵
Other metrics Before After Change
Lines 502 498 -4
Changed files Quality Before Quality After Quality Change
network.py 8.11 8.14 0.03 🔵
policy_training.py 8.51 8.52 0.01 🔵
util.py 8.66 8.66 0.00

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Overall Recommendation
network.py BaseNetwork.__init__ 3 369.39 4.94 Split out functionality
network.py PolicyNetwork.__init__ 1 187.79 6.23 Split out functionality
policy_training.py PolicyTraining.create_train_op 1 167.90 6.47 Split out functionality

Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Let us know what you think of it by mentioning @sourcery-ai in a comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants