pbrod/numdifftools

View on GitHub
src/numdifftools/core.py

Summary

Maintainability
A
3 hrs
Test Coverage

Consider using Python 3 style super() without arguments
Open

        super(Derivative, self).__init__(step=step,  **options)
Severity: Info
Found in src/numdifftools/core.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: 'Gradient', extra_parameter: n order : int, optionaln defines the order of the error term in the Taylor approximation used.n For 'central' and 'complex' methods, it must be an even number., ... }' instead of a call to 'dict'.
Open

    __doc__ = _CMN_DOC % dict(
Severity: Info
Found in src/numdifftools/core.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: order : int, optionaln defines the order of the error term in the Taylor approximation used.n For 'central' and 'complex' methods, it must be an even number., ... }' instead of a call to 'dict'.
Open

    __doc__ = _CMN_DOC % dict(
Severity: Info
Found in src/numdifftools/core.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: 'n-th derivative', extra_parameter: n order : int, optionaln defines the order of the error term in the Taylor approximation used.n For 'central' and 'complex' methods, it must be an even number.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/core.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(Hessdiag, self).__init__(f, step=step, method=method, n=2, order=order, **options)
Severity: Info
Found in src/numdifftools/core.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 many arguments (6/5)
Open

    def __init__(self, fun, step=None, method='central', order=2, n=1, **options):
Severity: Info
Found in src/numdifftools/core.py by pylint

Used when a function or method takes too many arguments.

Consider using Python 3 style super() without arguments
Open

        return super(Jacobian, self).__call__(np.atleast_1d(x), *args, **kwds)
Severity: Info
Found in src/numdifftools/core.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: '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/core.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

        result = super(Gradient, self).__call__(np.atleast_1d(x).ravel(), *args, **kwds)
Severity: Info
Found in src/numdifftools/core.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 Python 3 style super() without arguments
Open

        return super(Hessdiag, self).__call__(np.atleast_1d(x), *args, **kwds)
Severity: Info
Found in src/numdifftools/core.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: n order : int, optionaln defines the order of the error term in the Taylor approximation used.n For 'central' and 'complex' methods, it must be an even number., ... }' instead of a call to 'dict'.
Open

    __doc__ = _CMN_DOC % dict(
Severity: Info
Found in src/numdifftools/core.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 '{backward: 1, forward: 1}' instead of a call to 'dict'.
Open

            order = dict(backward=1, forward=1).get(method, 2)
Severity: Info
Found in src/numdifftools/core.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, step=step, method=method, order=order, **options)
Severity: Info
Found in src/numdifftools/core.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.

Number of parameters was 2 in '_Limit._step_generator' and is now 3 in overriding 'Derivative._step_generator' method
Open

    def _step_generator(self, step, options):
Severity: Minor
Found in src/numdifftools/core.py by pylint

Used when a method has a different number of arguments than in the implemented interface or in an overridden method. Extra arguments with default values are ignored.

Unable to import 'numpy'
Open

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

Used when pylint has been unable to import a module.

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/core.py and 1 other location - About 45 mins to fix
src/numdifftools/nd_algopy.py on lines 548..548

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

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/core.py and 1 other location - About 30 mins to fix
src/numdifftools/nd_algopy.py on lines 547..547

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/core.py and 9 other locations - About 30 mins to fix
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
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/core.py and 9 other locations - About 30 mins to fix
src/numdifftools/core.py on lines 116..116
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
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/core.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 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
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/core.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 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
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/core.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/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
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

Multiple spaces after ','
Open

        super(Derivative, self).__init__(step=step,  **options)
Severity: Minor
Found in src/numdifftools/core.py by pep8

Avoid extraneous whitespace after a comma or a colon.

Note: these checks are disabled by default

Okay: a = (1, 2)
E241: a = (1,  2)
E242: a = (1,\t2)

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/core.py by pylint

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

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

        msg = ('The {} step derivative method does only work on a real valued analytic '
Severity: Info
Found in src/numdifftools/core.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.

There are no issues that match your filters.

Category
Status