Skip to content

Add experiment class (Sourcery refactored)#62

Closed
sourcery-ai[bot] wants to merge 1 commit intoadd-experiment-classfrom
sourcery/add-experiment-class
Closed

Add experiment class (Sourcery refactored)#62
sourcery-ai[bot] wants to merge 1 commit intoadd-experiment-classfrom
sourcery/add-experiment-class

Conversation

@sourcery-ai
Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot commented Oct 8, 2020

Pull Request #61 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 add-experiment-class branch, then run:

git fetch origin sourcery/add-experiment-class
git merge --ff-only FETCH_HEAD
git reset HEAD^

@sourcery-ai sourcery-ai bot requested a review from janfreyberg October 8, 2020 08:25
if y is None:
pass
else:
if y is not None:
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function Labeller._annotation_iterator refactored with the following changes:

  • Swap if/else to remove empty if body (remove-pass-body)

Comment on lines -288 to +292
message = (
"<h1>{}".format(message)
+ '<i class="fa fa-spinner fa-spin"'
+ ' aria-hidden="true"></i>'
)
processing_display = widgets.HTML(value=message)
with self.feature_output:
message = (
"<h1>{}".format(message)
+ '<i class="fa fa-spinner fa-spin"'
+ ' aria-hidden="true"></i>'
)
processing_display = widgets.HTML(value=message)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function Labeller._render_processing refactored with the following changes:

  • Move assignments closer to their usage (move-assign)

Comment on lines -61 to -65
margin = (
return (
np.sort(probabilities, axis=1)[:, -1]
- np.sort(probabilities, axis=1)[:, -2]
)
return margin
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function margin refactored with the following changes:

  • Inline variable that is immediately returned (inline-immediately-returned-variable)

Comment on lines -89 to +88
certainty = probabilities.max(axis=-1)
return certainty
return probabilities.max(axis=-1)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function certainty refactored with the following changes:

  • Inline variable that is immediately returned (inline-immediately-returned-variable)

@sourcery-ai
Copy link
Copy Markdown
Author

sourcery-ai bot commented Oct 8, 2020

Sourcery Code Quality Report

This PR has an average code quality of 84.42%

Quality metrics Before After Change
Complexity 1.29 ⭐
Method Length 50.57 ⭐
Working memory 6.86 🙂
Quality % 84.42% %
Other metrics Before After Change
Lines 513
Changed files Quality Before Quality After Quality Change
src/superintendent/base.py % 82.23% ⭐ %
src/superintendent/acquisition_functions/functions.py % 88.78% ⭐ %

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

File Function Complexity Length Working Memory Quality Recommendation
src/superintendent/base.py Labeller.__init__ 7 ⭐ 296 ⛔ 21 ⛔ 33.59% 😞 Try splitting into smaller methods. Extract out complex expressions
src/superintendent/base.py Labeller.retrain 9 🙂 206 ⛔ 15 😞 41.30% 😞 Try splitting into smaller methods. Extract out complex expressions
src/superintendent/base.py Labeller._render_finished 0 39 ⭐ 11 😞 76.37% ⭐ Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


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.

1 participant