pbrod/numdifftools

View on GitHub
src/numdifftools/run_benchmark.py

Summary

Maintainability
A
35 mins
Test Coverage

Function _compute_benchmark has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def _compute_benchmark(functions, problem_sizes):
    result_list = []
    for n in problem_sizes:
        print('n=', n)
        num_methods = len(functions)
Severity: Minor
Found in src/numdifftools/run_benchmark.py - About 35 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Consider using '{method: method, order: order}' instead of a call to 'dict'.
Open

        options = dict(method=method, order=order)
Severity: Info
Found in src/numdifftools/run_benchmark.py by pylint

Emitted when using dict() to create a dictionary instead of a literal '{ ... }'. The literal is faster as it avoids an additional function call.

Too few public methods (1/2)
Open

class BenchmarkFunction(object):
Severity: Info
Found in src/numdifftools/run_benchmark.py by pylint

Used when class has too few public methods, so be sure it's really worth it.

Consider using '{method: method, order: order}' instead of a call to 'dict'.
Open

        options = dict(method=method, order=order)
Severity: Info
Found in src/numdifftools/run_benchmark.py by pylint

Emitted when using dict() to create a dictionary instead of a literal '{ ... }'. The literal is faster as it avoids an additional function call.

Too many local variables (18/15)
Open

def _compute_benchmark(functions, problem_sizes):
Severity: Info
Found in src/numdifftools/run_benchmark.py by pylint

Used when a function or method has too many local variables.

Class 'BenchmarkFunction' inherits from object, can be safely removed from bases in python3
Open

class BenchmarkFunction(object):
Severity: Info
Found in src/numdifftools/run_benchmark.py by pylint

Used when a class inherit from object, which under python3 is implicit, hence can be safely removed from bases.

Too many arguments (7/5)
Open

def _plot(plot, problem_sizes, objects, symbols, ylabel='', loc=2, logx=False):
Severity: Info
Found in src/numdifftools/run_benchmark.py by pylint

Used when a function or method takes too many arguments.

Unable to import 'matplotlib.pyplot'
Open

import matplotlib.pyplot as plt
Severity: Critical
Found in src/numdifftools/run_benchmark.py by pylint

Used when pylint has been unable to import a module.

Unable to import 'numpy'
Open

import numpy as np
Severity: Critical
Found in src/numdifftools/run_benchmark.py by pylint

Used when pylint has been unable to import a module.

Imports from package numdifftools are not grouped
Open

    import numdifftools.nd_algopy as nda
Severity: Info
Found in src/numdifftools/run_benchmark.py by pylint

Used when imports are not grouped by packages.

Attribute name A doesn't conform to '[a-z_][a-z0-9_]{2,30}$' pattern ('[a-z_][a-z0-9_]{2,30}$' pattern)
Open

        self.A = np.dot(A.T, A)
Severity: Info
Found in src/numdifftools/run_benchmark.py by pylint

Used when the name doesn't conform to naming rules associated to its type (constant, variable, class...).

Missing module docstring
Open

from __future__ import absolute_import, print_function
Severity: Info
Found in src/numdifftools/run_benchmark.py by pylint

Used when a module has no docstring. Empty modules do not require a docstring.

Function name run_gradient_and_hessian_benchmarks doesn't conform to '[a-z_][a-z0-9_]{2,30}$' pattern ('[a-z_][a-z0-9_]{2,30}$' pattern)
Open

def run_gradient_and_hessian_benchmarks(gradient_funs, hessian_funs,
Severity: Info
Found in src/numdifftools/run_benchmark.py by pylint

Used when the name doesn't conform to naming rules associated to its type (constant, variable, class...).

Missing function or method docstring
Open

def loglimits(data, border=0.05):
Severity: Info
Found in src/numdifftools/run_benchmark.py by pylint

Used when a function or method has no docstring. Some special methods like init do not require a docstring.

Missing function or method docstring
Open

def compute_gradients(gradient_funs, problem_sizes):
Severity: Info
Found in src/numdifftools/run_benchmark.py by pylint

Used when a function or method has no docstring. Some special methods like init do not require a docstring.

Formatting a regular string which could be a f-string
Open

    adaptiv_txt = '_adaptive_{0:d}_{1!s}_{2:d}'.format(epsilon.num_steps,
Severity: Info
Found in src/numdifftools/run_benchmark.py by pylint

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.

Argument name xi doesn't conform to '[a-z_][a-z0-9_]{2,30}$' pattern ('[a-z_][a-z0-9_]{2,30}$' pattern)
Open

    def __call__(self, xi):
Severity: Info
Found in src/numdifftools/run_benchmark.py by pylint

Used when the name doesn't conform to naming rules associated to its type (constant, variable, class...).

Variable name A doesn't conform to '[a-z_][a-z0-9_]{2,30}$' pattern ('[a-z_][a-z0-9_]{2,30}$' pattern)
Open

        A = np.arange(n * n, dtype=float).reshape((n, n))
Severity: Info
Found in src/numdifftools/run_benchmark.py by pylint

Used when the name doesn't conform to naming rules associated to its type (constant, variable, class...).

Missing function or method docstring
Open

def plot_errors(error_objects, problem_sizes, symbols):
Severity: Info
Found in src/numdifftools/run_benchmark.py by pylint

Used when a function or method has no docstring. Some special methods like init do not require a docstring.

Missing function or method docstring
Open

def run_gradient_and_hessian_benchmarks(gradient_funs, hessian_funs,
Severity: Info
Found in src/numdifftools/run_benchmark.py by pylint

Used when a function or method has no docstring. Some special methods like init do not require a docstring.

Missing function or method docstring
Open

def main(problem_sizes=(4, 8, 16, 32, 64, 96)):
Severity: Info
Found in src/numdifftools/run_benchmark.py by pylint

Used when a function or method has no docstring. Some special methods like init do not require a docstring.

Missing function or method docstring
Open

def plot_runtimes(run_time_objects, problem_sizes, symbols):
Severity: Info
Found in src/numdifftools/run_benchmark.py by pylint

Used when a function or method has no docstring. Some special methods like init do not require a docstring.

Missing function or method docstring
Open

def compute_hessians(hessian_funs, problem_sizes):
Severity: Info
Found in src/numdifftools/run_benchmark.py by pylint

Used when a function or method has no docstring. Some special methods like init do not require a docstring.

There are no issues that match your filters.

Category
Status