Sourcery Starbot ⭐ refactored Tybirk/OCAIM#1
Sourcery Starbot ⭐ refactored Tybirk/OCAIM#1SourceryAI wants to merge 1 commit intoTybirk:masterfrom
Conversation
| feature_matrix = np.zeros(numberOfFeatures*numberOfNodes).reshape(numberOfNodes, numberOfFeatures) | ||
|
|
||
| featureToIndex = dict() | ||
| featureToIndex = {} |
There was a problem hiding this comment.
Function get_feature_matrix refactored with the following changes:
- Replace dict() with {} (
dict-literal)
| G = nx.Graph() | ||
| else: | ||
| G = nx.DiGraph() | ||
| G = nx.DiGraph() if directed else nx.Graph() |
There was a problem hiding this comment.
Function read_graph refactored with the following changes:
- Swap if/else branches of if expression to remove negation (
swap-if-expression) - Replace if statement with if expression (
assign-if-exp)
| for i in range(numberOfEdges): | ||
| for _ in range(numberOfEdges): |
There was a problem hiding this comment.
Function create_graph refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore)
|
|
||
| if w is None: w = np.zeros(len(X[1])) | ||
| for i in range(epochs): | ||
| for _ in range(epochs): |
There was a problem hiding this comment.
Function mini_batch_grad_descent refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore)
This removes the following comments ( why? ):
# lr = lr * np.linalg.norm(grad)/len(y)
| if not linear: | ||
| return sigmoid(feature_mat @ parameters) | ||
| else: | ||
| edge_probs = [max(min(feature_mat[i, :]@linear_parameters, 1),0) for i in range(feature_mat.shape[0])] | ||
| return edge_probs | ||
| return ( | ||
| [ | ||
| max(min(feature_mat[i, :] @ linear_parameters, 1), 0) | ||
| for i in range(feature_mat.shape[0]) | ||
| ] | ||
| if linear | ||
| else sigmoid(feature_mat @ parameters) | ||
| ) |
There was a problem hiding this comment.
Function get_edge_probabilities refactored with the following changes:
- Swap if/else branches of if expression to remove negation (
swap-if-expression) - Replace if statement with if expression (
assign-if-exp) - Inline variable that is immediately returned (
inline-immediately-returned-variable)
| while len(new_activations) > 0: | ||
| while new_activations: |
There was a problem hiding this comment.
Function simulate_activations refactored with the following changes:
- Simplify sequence length comparison (
simplify-len-comparison)
| message = list(bestMessage) | ||
| for feature in range(1, numberFeatures): | ||
| index += 1 | ||
|
|
||
| currentResult = 0 | ||
| for index, feature in enumerate(range(1, numberFeatures), start=1): |
There was a problem hiding this comment.
Function greedy refactored with the following changes:
- Move assignment closer to its usage within a block (
move-assign-in-block) - Replace manual loop counter with call to enumerate (
convert-to-enumerate) - Swap if/else branches (
swap-if-else-branches) - Merge else clause's nested if statement into elif (
merge-else-if-into-elif) - Replace unused for index with underscore (
for-index-underscore)
| plt.xlabel(xlabel, fontsize=40) | ||
| if title: | ||
| plt.title('%s' %(title), fontsize = 48) | ||
| plt.title(f'{title}', fontsize = 48) |
There was a problem hiding this comment.
Function visualiseResults refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
Thanks for starring sourcery-ai/sourcery ✨ 🌟 ✨
Here's your pull request refactoring your most popular Python repo.
If you want Sourcery to refactor all your Python repos and incoming pull requests install our bot.
Review changes via command line
To manually merge these changes, make sure you're on the
masterbranch, then run: