Skip to content

Commit ce7db66

Browse files
committed
Merge commit 'cf4b6b7b79523ad851a37e2449d11900de8265a4'
1 parent f6ae234 commit ce7db66

19 files changed

+3221
-135
lines changed

.coverage

0 Bytes
Binary file not shown.

.coveragerc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[run]
2+
source = openpiv
3+
omit =
4+
*/test/*
5+
*/__init__.py
6+
*/setup.py
7+
8+
[report]
9+
exclude_lines =
10+
pragma: no cover
11+
def __repr__
12+
raise NotImplementedError
13+
if __name__ == .__main__.:
14+
pass
15+
raise ImportError

.github/workflows/testing.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ on: [push]
44

55
jobs:
66
build:
7-
87
runs-on: ubuntu-latest
98
strategy:
109
matrix:
11-
python-version: ["3.10", "3.11","3.12"]
10+
python-version: ["3.10", "3.11", "3.12"]
1211
poetry-version: [1.5.0]
1312

1413
steps:

openpiv/lib.py

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33

44
def replace_nans(array, max_iter, tol, kernel_size=2, method="disk"):
5-
65
"""Replace NaN elements in an array using an iterative image inpainting
76
algorithm.
87
@@ -18,26 +17,15 @@ def replace_nans(array, max_iter, tol, kernel_size=2, method="disk"):
1817
threshold.
1918
2019
Methods:
21-
22-
localmean - A square kernel where all elements have the same value,
23-
weights are equal to n/( (2*kernel_size+1)**2 -1 ),
24-
where n is the number of non-NaN elements.
25-
disk - A circular kernel where all elements have the same value,
26-
kernel is calculated by::
27-
if ((S-i)**2 + (S-j)**2)**0.5 <= S:
28-
kernel[i,j] = 1.0
29-
else:
30-
kernel[i,j] = 0.0
31-
where S is the kernel radius.
32-
distance - A circular inverse distance kernel where elements are
33-
weighted proportional to their distance away from the
34-
center of the kernel, elements farther away have less
35-
weight. Elements outside the specified radius are set
36-
to 0.0 as in 'disk', the remaining of the weights are
37-
calculated as::
38-
maxDist = ((S)**2 + (S)**2)**0.5
39-
kernel[i,j] = -1*(((S-i)**2 + (S-j)**2)**0.5 - maxDist)
40-
where S is the kernel radius.
20+
localmean - A square kernel where all elements have the same weight.
21+
disk - A circular kernel where all elements have the same weight.
22+
distance - A circular kernel where the weight of each element depends
23+
on its distance from the center of the kernel. The weights
24+
are given by a function of the form:
25+
w_i = 1 - (d_i / d_max)^2
26+
where d_i is the distance from the center, and d_max is the
27+
distance of the element farthest from the center.
28+
This method requires SciPy.
4129
4230
Parameters
4331
----------
@@ -68,6 +56,9 @@ def replace_nans(array, max_iter, tol, kernel_size=2, method="disk"):
6856
a copy of the input array, where NaN elements have been replaced.
6957
7058
"""
59+
# Check if there are any NaNs to replace
60+
if not np.any(np.isnan(array)):
61+
return array.copy()
7162

7263
kernel_size = int(kernel_size)
7364
filled = array.copy()

0 commit comments

Comments
 (0)