pbrod/numdifftools

View on GitHub
src/numdifftools/nd_algopy.py

Summary

Maintainability
B
6 hrs
Test Coverage

Consider using '{derivative: 'n-th derivative', extra_parameter: 'n n: int, optionaln Order of the derivative.', ... }' instead of a call to 'dict'.
Open

    __doc__ = _cmn_doc % dict(
Severity: Info
Found in src/numdifftools/nd_algopy.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.

Consider using '{derivative: 'Hessian diagonal', extra_parameter: '', returns: 'n Returnsn -------n hessdiag : ndarrayn Hessian diagonal array of partial second order derivatives.n ', ... }' instead of a call to 'dict'.
Open

    __doc__ = _cmn_doc % dict(
Severity: Info
Found in src/numdifftools/nd_algopy.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.

Consider using Python 3 style super() without arguments
Open

        return np.diag(super(Hessdiag, self)._reverse(x, *args, **kwds))
Severity: Info
Found in src/numdifftools/nd_algopy.py by pylint

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.

Consider using '{derivative: 'Jacobian', extra_parameter: '', extra_note: '', ... }' instead of a call to 'dict'.
Open

    __doc__ = _cmn_doc % dict(
Severity: Info
Found in src/numdifftools/nd_algopy.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.

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

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

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

Consider using '{derivative: 'Hessian', extra_parameter: '', returns: 'n Returnsn -------n hess : ndarrayn array of partial second derivatives, Hessiann ', ... }' instead of a call to 'dict'.
Open

    __doc__ = _cmn_doc % dict(
Severity: Info
Found in src/numdifftools/nd_algopy.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.

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

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

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

Consider using '{derivative: 'Gradient', extra_parameter: '', extra_note: '', ... }' instead of a call to 'dict'.
Open

    __doc__ = _cmn_doc % dict(
Severity: Info
Found in src/numdifftools/nd_algopy.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.

Consider using Python 3 style super() without arguments
Open

        return np.atleast_2d(super(Jacobian, self)._forward(x, *args, **kwds))
Severity: Info
Found in src/numdifftools/nd_algopy.py by pylint

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 Taylor(object):
Severity: Info
Found in src/numdifftools/nd_algopy.py by pylint

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

Consider using '{backward: 'reverse'}' instead of a call to 'dict'.
Open

        name = '_' + dict(backward='reverse').get(self.method, self.method)
Severity: Info
Found in src/numdifftools/nd_algopy.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.

Consider using Python 3 style super() without arguments
Open

        super(Hessian, self).__init__(f, n=2, method=method,
Severity: Info
Found in src/numdifftools/nd_algopy.py by pylint

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.

Unable to import 'numpy'
Open

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

Used when pylint has been unable to import a module.

Unable to import 'scipy'
Open

from scipy import special
Severity: Critical
Found in src/numdifftools/nd_algopy.py by pylint

Used when pylint has been unable to import a module.

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    def _forward(self, x, *args, **kwds):
        # forward mode without building the computational graph

        tmp = UTPM.init_jacobian(x)
        y = self.fun(tmp, *args, **kwds)
Severity: Major
Found in src/numdifftools/nd_algopy.py and 1 other location - About 1 hr to fix
src/numdifftools/nd_algopy.py on lines 368..371

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 42.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    def _reverse(self, x, *args, **kwds):
        x = np.atleast_1d(x)
        c_graph = self.computational_graph(x, *args, **kwds)
        return c_graph.jacobian(x)
Severity: Major
Found in src/numdifftools/nd_algopy.py and 1 other location - About 1 hr to fix
src/numdifftools/nd_algopy.py on lines 279..284

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 42.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

    return Derivative(lambda t: f(x0 + t * vec), **options)(0)
Severity: Minor
Found in src/numdifftools/nd_algopy.py and 1 other location - About 45 mins to fix
src/numdifftools/core.py on lines 341..341

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 35.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 10 locations. Consider refactoring.
Open

    __doc__ = _cmn_doc % dict(
Severity: Major
Found in src/numdifftools/nd_algopy.py and 9 other locations - About 30 mins to fix
src/numdifftools/core.py on lines 116..116
src/numdifftools/core.py on lines 346..346
src/numdifftools/core.py on lines 436..436
src/numdifftools/core.py on lines 498..498
src/numdifftools/core.py on lines 543..543
src/numdifftools/nd_algopy.py on lines 233..233
src/numdifftools/nd_algopy.py on lines 294..294
src/numdifftools/nd_algopy.py on lines 376..376
src/numdifftools/nd_algopy.py on lines 441..441

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 32.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

    vec = np.reshape(vec / np.linalg.norm(vec.ravel()), x0.shape)
Severity: Minor
Found in src/numdifftools/nd_algopy.py and 1 other location - About 30 mins to fix
src/numdifftools/core.py on lines 340..340

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 32.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 10 locations. Consider refactoring.
Open

    __doc__ = _cmn_doc % dict(
Severity: Major
Found in src/numdifftools/nd_algopy.py and 9 other locations - About 30 mins to fix
src/numdifftools/core.py on lines 116..116
src/numdifftools/core.py on lines 346..346
src/numdifftools/core.py on lines 436..436
src/numdifftools/core.py on lines 498..498
src/numdifftools/core.py on lines 543..543
src/numdifftools/nd_algopy.py on lines 169..169
src/numdifftools/nd_algopy.py on lines 233..233
src/numdifftools/nd_algopy.py on lines 376..376
src/numdifftools/nd_algopy.py on lines 441..441

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 32.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 10 locations. Consider refactoring.
Open

    __doc__ = _cmn_doc % dict(
Severity: Major
Found in src/numdifftools/nd_algopy.py and 9 other locations - About 30 mins to fix
src/numdifftools/core.py on lines 116..116
src/numdifftools/core.py on lines 346..346
src/numdifftools/core.py on lines 436..436
src/numdifftools/core.py on lines 498..498
src/numdifftools/core.py on lines 543..543
src/numdifftools/nd_algopy.py on lines 169..169
src/numdifftools/nd_algopy.py on lines 233..233
src/numdifftools/nd_algopy.py on lines 294..294
src/numdifftools/nd_algopy.py on lines 376..376

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 32.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 10 locations. Consider refactoring.
Open

    __doc__ = _cmn_doc % dict(
Severity: Major
Found in src/numdifftools/nd_algopy.py and 9 other locations - About 30 mins to fix
src/numdifftools/core.py on lines 116..116
src/numdifftools/core.py on lines 346..346
src/numdifftools/core.py on lines 436..436
src/numdifftools/core.py on lines 498..498
src/numdifftools/core.py on lines 543..543
src/numdifftools/nd_algopy.py on lines 169..169
src/numdifftools/nd_algopy.py on lines 233..233
src/numdifftools/nd_algopy.py on lines 294..294
src/numdifftools/nd_algopy.py on lines 441..441

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 32.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 10 locations. Consider refactoring.
Open

    __doc__ = _cmn_doc % dict(
Severity: Major
Found in src/numdifftools/nd_algopy.py and 9 other locations - About 30 mins to fix
src/numdifftools/core.py on lines 116..116
src/numdifftools/core.py on lines 346..346
src/numdifftools/core.py on lines 436..436
src/numdifftools/core.py on lines 498..498
src/numdifftools/core.py on lines 543..543
src/numdifftools/nd_algopy.py on lines 169..169
src/numdifftools/nd_algopy.py on lines 294..294
src/numdifftools/nd_algopy.py on lines 376..376
src/numdifftools/nd_algopy.py on lines 441..441

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 32.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Missing function or method docstring
Open

    def computational_graph(self, x, *args, **kwds):
Severity: Info
Found in src/numdifftools/nd_algopy.py by pylint

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

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

            cg = algopy.CGraph()
Severity: Info
Found in src/numdifftools/nd_algopy.py by pylint

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

Constant name _cmn_doc doesn't conform to '(([A-Z_][A-Z0-9_]*)|(__.*__))$' pattern ('(([A-Z_][A-Z0-9_]*)|(__.*__))$' pattern)
Open

_cmn_doc = """
Severity: Info
Found in src/numdifftools/nd_algopy.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 fun(self):
Severity: Info
Found in src/numdifftools/nd_algopy.py by pylint

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

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

        x0 = np.asarray(x, dtype=float)
Severity: Info
Found in src/numdifftools/nd_algopy.py by pylint

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

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

def directionaldiff(f, x0, vec, **options):
Severity: Info
Found in src/numdifftools/nd_algopy.py by pylint

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

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

        df = fun(x0, *args, **kwds)
Severity: Info
Found in src/numdifftools/nd_algopy.py by pylint

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

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

        x0 = np.asarray(x)
Severity: Info
Found in src/numdifftools/nd_algopy.py by pylint

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

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

        d, n = 2 + 1, x.size
Severity: Info
Found in src/numdifftools/nd_algopy.py by pylint

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

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

        P = 1
Severity: Info
Found in src/numdifftools/nd_algopy.py by pylint

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

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

        z0 = self.fun(y, *args, **kwds)
Severity: Info
Found in src/numdifftools/nd_algopy.py by pylint

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

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

        H = z.data[2, ...] * 2
Severity: Info
Found in src/numdifftools/nd_algopy.py by pylint

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

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

    def __call__(self, z0=0):
Severity: Info
Found in src/numdifftools/nd_algopy.py by pylint

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

There are no issues that match your filters.

Category
Status