Passed
Push — master ( 573345...9597ff )
by Giacomo
06:15
created

hawc_hal.interpolation.log_log_interpolation   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 19
dl 0
loc 33
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A LogLogInterpolator.integral() 0 10 1
A LogLogInterpolator.__call__() 0 3 1
A LogLogInterpolator.__init__() 0 9 1
1
import numpy as np
0 ignored issues
show
Coding Style introduced by
This module should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
introduced by
Unable to import 'numpy'
Loading history...
2
from numpy import log10
0 ignored issues
show
introduced by
Unable to import 'numpy'
Loading history...
3
from math import log10 as mlog10
0 ignored issues
show
introduced by
standard import "from math import log10 as mlog10" should be placed before "import numpy as np"
Loading history...
4
import scipy.interpolate
0 ignored issues
show
introduced by
Unable to import 'scipy.interpolate'
Loading history...
5
6
7
class LogLogInterpolator(object):  # pragma: no cover
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
8
9
    def __init__(self, x, y, k=2):
10
11
        y = y.astype(np.float64)
12
        y = np.clip(y, 2 * np.finfo(np.float64).tiny, None)
13
14
        logx = log10(x)
15
        logy = log10(y)
16
17
        self._interp = scipy.interpolate.InterpolatedUnivariateSpline(logx, logy, k=k)
18
19
    def __call__(self, x):
0 ignored issues
show
Coding Style Naming introduced by
The name x does not conform to the argument naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
20
21
        return 10**self._interp(log10(x))
22
23
    def integral(self, a, b, n_points=100, k=1):
0 ignored issues
show
Coding Style Naming introduced by
The name a does not conform to the argument naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style Naming introduced by
The name b does not conform to the argument naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
24
25
        # Make a second interpolator
26
        xx = np.logspace(mlog10(a), mlog10(b), n_points)
0 ignored issues
show
Coding Style Naming introduced by
The name xx does not conform to the variable naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
27
28
        yy = self.__call__(xx)
0 ignored issues
show
Coding Style Naming introduced by
The name yy does not conform to the variable naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
29
30
        int_interp = scipy.interpolate.InterpolatedUnivariateSpline(xx, yy, k=k)
31
32
        return int_interp.integral(a, b)
0 ignored issues
show
Coding Style introduced by
Final newline missing
Loading history...