-
Notifications
You must be signed in to change notification settings - Fork 54
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 #175
Conversation
# Create variables | ||
x = {} | ||
for i in range(n): | ||
x[i] = solver.BoolVar("x_%d" % i) | ||
|
||
x = {i: solver.BoolVar("x_%d" % i) for i in range(n)} |
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 knapsack_model
refactored with the following changes:
- Convert for loop into dictionary comprehension (
dict-comprehension
)
This removes the following comments ( why? ):
# Create variables
@@ -6,6 +6,7 @@ | |||
@author: fabian | |||
""" | |||
|
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.
Lines 27-27
refactored with the following changes:
- Unwrap a constant iterable constructor (
unwrap-iterable-construction
)
if "dev" in version: | ||
# remove the dev description and reduce by minor one release | ||
release = "master" | ||
else: | ||
release = version | ||
|
||
|
||
release = "master" if "dev" in version else version |
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.
Lines 26-32
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
)
This removes the following comments ( why? ):
# remove the dev description and reduce by minor one release
@@ -4,6 +4,7 @@ | |||
Linopy module for solving lp files with different solvers. | |||
""" | |||
|
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.
Lines 33-67
refactored with the following changes:
- Remove redundant exceptions from an except clause [×4] (
remove-redundant-exception
) - Replace length-one exception tuple with exception [×4] (
simplify-single-exception-tuple
) - Use
contextlib
'ssuppress
method to silence an error [×4] (use-contextlib-suppress
)
try: | ||
with contextlib.suppress(Exception): | ||
logger.warning("Solution status unknown. Trying to parse solution.") | ||
return func() | ||
except Exception: | ||
pass |
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 safe_get_solution
refactored with the following changes:
- Use
contextlib
'ssuppress
method to silence an error (use-contextlib-suppress
)
coord = tuple([var.indexes[c][0] for c in var.dims]) | ||
coord = tuple(var.indexes[c][0] for c in var.dims) |
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 test_scalar_linear_expression_repr
refactored with the following changes:
- Replace unneeded comprehension with generator (
comprehension-to-generator
)
coord = tuple([var.indexes[c][0] for c in var.dims]) | ||
coord = tuple(var.indexes[c][0] for c in var.dims) |
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 test_single_linear_repr
refactored with the following changes:
- Replace unneeded comprehension with generator (
comprehension-to-generator
)
repr(1 * u[0, 0] >= 0) | ||
repr(u[0, 0] >= 0) |
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 test_scalar_constraint_repr
refactored with the following changes:
- Simplify numeric comparison (
simplify-numeric-comparison
)
coord = tuple([var.indexes[c][0] for c in var.dims]) | ||
repr(1 * var.loc[coord] == 0) | ||
coord = tuple(var.indexes[c][0] for c in var.dims) | ||
repr(var.loc[coord] == 0) |
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 test_single_constraint_repr
refactored with the following changes:
- Replace unneeded comprehension with generator (
comprehension-to-generator
) - Simplify numeric comparison (
simplify-numeric-comparison
)
x[0:5] | ||
x[:5] |
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 test_variable_getter
refactored with the following changes:
- Replace a[0:x] with a[:x] and a[x:len(a)] with a[x:] (
remove-redundant-slice-index
)
Codecov ReportAll modified lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #175 +/- ##
==========================================
+ Coverage 87.28% 87.29% +0.01%
==========================================
Files 14 14
Lines 3122 3110 -12
Branches 708 714 +6
==========================================
- Hits 2725 2715 -10
+ Misses 289 287 -2
Partials 108 108
☔ View full report in Codecov by Sentry. |
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:Help us improve this pull request!