hawc_hal.interpolation.irregular_grid   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 21
dl 0
loc 40
rs 10
c 0
b 0
f 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
A interpolate() 0 3 1
A interp_weights() 0 15 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A FastLinearInterpolatorIrregularGrid.__call__() 0 3 1
A FastLinearInterpolatorIrregularGrid.__init__() 0 5 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...
2
from ..util import cartesian
3
import scipy.spatial.qhull as qhull
0 ignored issues
show
introduced by
third party import "import scipy.spatial.qhull as qhull" should be placed before "from ..util import cartesian"
Loading history...
4
5
6
# Mark this as no cover because they are not used at the moment
7
def interp_weights(xy, uv, d=2):  # pragma: no cover
0 ignored issues
show
Coding Style introduced by
This function 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...
Coding Style Naming introduced by
Argument name "xy" doesn't conform to snake_case naming style ('(([a-z_][a-z0-9_]2,30)|(_[a-z0-9_]*)|(__[a-z][a-z0-9_]+__))$' pattern)

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
Argument name "uv" doesn't conform to snake_case naming style ('(([a-z_][a-z0-9_]2,30)|(_[a-z0-9_]*)|(__[a-z][a-z0-9_]+__))$' pattern)

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
Argument name "d" doesn't conform to snake_case naming style ('(([a-z_][a-z0-9_]2,30)|(_[a-z0-9_]*)|(__[a-z][a-z0-9_]+__))$' pattern)

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...
8
9
    tri = qhull.Delaunay(xy)
0 ignored issues
show
introduced by
Module 'scipy.spatial.qhull' has not 'Delaunay' member, but source is unavailable. Consider adding this module to extension-pkg-whitelist if you want to perform analysis based on run-time introspection of living objects.
Loading history...
10
11
    simplex = tri.find_simplex(uv)
12
13
    vertices = np.take(tri.simplices, simplex, axis=0)
14
15
    temp = np.take(tri.transform, simplex, axis=0)
16
17
    delta = uv - temp[:, d]
18
19
    bary = np.einsum('njk,nk->nj', temp[:, :d, :], delta)
20
21
    return vertices, np.hstack((bary, 1 - bary.sum(axis=1, keepdims=True)))
22
23
24
def interpolate(values, vtx, wts):  # pragma: no cover
0 ignored issues
show
Coding Style introduced by
This function 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...
25
26
    return np.einsum('nj,nj->n', np.take(values, vtx), wts)
27
28
29
class FastLinearInterpolatorIrregularGrid(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...
30
31
    def __init__(self, data_shape, new_coords):
32
33
        old_coords = cartesian([np.arange(data_shape[0]), np.arange(data_shape[1])])
34
35
        self._vtx, self._wts = interp_weights(old_coords, new_coords)
36
37
    def __call__(self, data):
38
39
        return interpolate(data, self._vtx, self._wts)
0 ignored issues
show
Coding Style introduced by
Final newline missing
Loading history...