Showing 591 of 591 total issues
Formatting a regular string which could be a f-string Open
print('n={}, scale={:.2f}'.format(n, default_scale(method, n, order)))
- Read upRead up
- Exclude checks
Used when we detect a string that is being formatted with format() or % which could potentially be a f-string. The use of f-strings is preferred. Requires Python 3.6 and py-version >= 3.6
.
Formatting a regular string which could be a f-string Open
print('n={}, mean scale={:.2f}, median scale={:.2f}'.format(n,
- Read upRead up
- Exclude checks
Used when we detect a string that is being formatted with format() or % which could potentially be a f-string. The use of f-strings is preferred. Requires Python 3.6 and py-version >= 3.6
.
Unused MaxStepGenerator imported from numdifftools.step_generators Open
from numdifftools.step_generators import default_scale, MinStepGenerator, MaxStepGenerator
- Read upRead up
- Exclude checks
Used when an imported module or variable is not used.
Consider using Python 3 style super() without arguments Open
return super(Gradient, self).__call__(np.atleast_1d(x).ravel(),
- Read upRead up
- Exclude checks
Emitted when calling the super() builtin with the current class and instance. On Python 3 these arguments are the default and they can be omitted.
Too few public methods (1/2) Open
class Gradient(Jacobian):
- Read upRead up
- Exclude checks
Used when class has too few public methods, so be sure it's really worth it.
Import outside toplevel (sphinx.application.Sphinx) Open
from sphinx.application import Sphinx
- Read upRead up
- Exclude checks
Used when an import statement is used anywhere other than the module toplevel. Move this import to the top of the file.
Similar lines in 2 files Open
#!/usr/bin/env python
- Read upRead up
- Exclude checks
Indicates that a set of similar lines has been detected among multiple file. This usually means that the code should be refactored to avoid this duplication. ==numdifftools.finitedifference:[562:582] ==numdifftools.limits:[210:219] originalshape = np.shape(sequence[0]) fdel = np.vstack([np.ravel(r) for r in sequence]) one = np.ones(originalshape) h = np.vstack([np.ravel(one * step) for step in steps]) assert(fdel.size == h.size, 'fun did not return data of correct ' 'size (it must be vectorized)') return fdel, h, originalshape
def apply(self, sequence, steps, step_ratio=2.0): ``` Apply finite difference rule along the first axis.
Return derivative estimates of fun at x0 for a sequence of stepsizes h
Parameters
sequence: finite differences steps: steps
TODO found Open
notes=FIXME,XXX,TODO
- Exclude checks
BUG found Open
* BUG: added missing derivative order, n to Gradient, Hessian, Jacobian.
- Exclude checks
XXX found Open
notes=FIXME,XXX,TODO
- Exclude checks
Catching too general exception Exception Open
except Exception:
- Read upRead up
- Exclude checks
If you use a naked except Exception:
clause, you might end up catching exceptions other than the ones you expect to catch. This can hide bugs or make it harder to debug programs when unrelated errors are hidden.
Missing function or method docstring Open
def run_all_benchmarks(method='forward', order=4, x_values=(0.1, 0.5, 1.0, 5), n_max=11,
- Read upRead up
- Exclude checks
Used when a function or method has no docstring. Some special methods like init do not require a docstring.
Too many arguments (6/5) Open
def benchmark(x=0.0001, dfun=None, fd=None, name='', scales=None, show_plot=True):
- Read upRead up
- Exclude checks
Used when a function or method takes too many arguments.
Unused argument 'order' Open
def __init__(self, fun, step=None, method='central', order=2,
- Read upRead up
- Exclude checks
Used when a function or method argument is not used.
Consider using '{n
: n, order
: order, method
: method, fun
: name, error
: np.nan, ... }' instead of a call to 'dict'. Open
return dict(n=n, order=order, method=method, fun=name,
- Read upRead up
- Exclude checks
Emitted when using dict() to create a dictionary instead of a literal '{ ... }'. The literal is faster as it avoids an additional function call.
Refactor this function to reduce its Cognitive Complexity from 16 to the 15 allowed. Open
def _dea(self, epstab, n):
- Read upRead up
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.
See
Too many local variables (16/15) Open
def run_all_benchmarks(method='forward', order=4, x_values=(0.1, 0.5, 1.0, 5), n_max=11,
- Read upRead up
- Exclude checks
Used when a function or method has too many local variables.
Unused approx_fprime imported from scipy.optimize Open
from scipy.optimize import approx_fprime
- Read upRead up
- Exclude checks
Used when an imported module or variable is not used.
TODO found Open
TODO: The following does not work:
- Exclude checks
Formatting a regular string which could be a f-string Open
error = float('{:.3g}'.format(relativ_errors[i]))
- Read upRead up
- Exclude checks
Used when we detect a string that is being formatted with format() or % which could potentially be a f-string. The use of f-strings is preferred. Requires Python 3.6 and py-version >= 3.6
.