-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make 3rd-order prism kernels return np.nan on vertices
Make the 3rd order kernel functions for prisms to return `np.nan` when the observation points matches any vertex of the prisms. Fixes division-by-zero error when evaluating `kernel_enu` when `radius` is zero, and makes the behaviour consistent with the other third-order kernels.
- Loading branch information
1 parent
1392845
commit 826cf4b
Showing
2 changed files
with
77 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
""" | ||
Additional tests to prism kernels. | ||
""" | ||
|
||
import pytest | ||
import numpy as np | ||
|
||
from choclo.prism import ( | ||
kernel_eee, | ||
kernel_nnn, | ||
kernel_uuu, | ||
kernel_een, | ||
kernel_eeu, | ||
kernel_enn, | ||
kernel_nnu, | ||
kernel_euu, | ||
kernel_nuu, | ||
kernel_enu, | ||
) | ||
|
||
|
||
class TestThirdOrderKernelsOnVertex: | ||
""" | ||
Test if third-order kernels evaluated on a vertex return np.nan. | ||
This functionality is meant to be supported for the public usage of this | ||
kernels, although the forward modelling functions within Choclo won't use | ||
it since they filter out singular points before they call kernels. | ||
""" | ||
|
||
KERNELS = ( | ||
kernel_eee, | ||
kernel_nnn, | ||
kernel_uuu, | ||
kernel_een, | ||
kernel_eeu, | ||
kernel_enn, | ||
kernel_nnu, | ||
kernel_euu, | ||
kernel_nuu, | ||
kernel_enu, | ||
) | ||
|
||
@pytest.mark.parametrize("kernel", KERNELS) | ||
def test_third_order_kernels_on_vertex(self, kernel): | ||
easting, northing, upward = 0.0, 0.0, 0.0 | ||
radius = 0.0 | ||
result = kernel(easting, northing, upward, radius) | ||
assert np.isnan(result) |