Skip to content

Commit

Permalink
Adds non_exact testing
Browse files Browse the repository at this point in the history
  • Loading branch information
nannau committed Jun 26, 2020
1 parent f23ef04 commit 4444ec6
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,61 @@ def test_core_krige_3d():
assert ss == approx(0.0, rel=1e-3)


def test_non_exact():
# custom data for this test
data = np.array(
[[0.0, 0.0, 0.47], [1.5, 1.5, 0.56], [3, 3, 0.74], [4.5, 4.5, 1.47],]
)

# construct grid points so diagonal
# is identical to input points
gridx = np.arange(0.0, 4.51, 1.5)
gridy = np.arange(0.0, 4.51, 1.5)

ok = OrdinaryKriging(
data[:, 0],
data[:, 1],
data[:, 2],
variogram_model="exponential",
variogram_parameters=[500.0, 3000.0, 5.0],
)
z, ss = ok.execute("grid", gridx, gridy, backend="vectorized")

ok_non_exact = OrdinaryKriging(
data[:, 0],
data[:, 1],
data[:, 2],
variogram_model="exponential",
variogram_parameters=[500.0, 3000.0, 5.0],
exact_values=False,
)
z_non_exact, ss_non_exact = ok_non_exact.execute(
"grid", gridx, gridy, backend="vectorized"
)

in_values = np.diag(z)

# test that krig field
# at input location are identical
# to the inputs themselves with
# exact_values == True
assert_allclose(in_values, data[:, 2])

# test that krig field
# at input location are different
# than the inputs themselves
# with exact_values == False
assert ~np.allclose(in_values, data[:, 2])

# test that off diagonal values are the same
# by filling with dummy value and comparing
# each entry in array
np.fill_diagonal(z, 0.0)
np.fill_diagonal(z_non_exact, 0.0)

assert_allclose(z, z_non_exact)


def test_ok(validation_ref):

# Test to compare OK results to those obtained using KT3D_H2O.
Expand Down

0 comments on commit 4444ec6

Please sign in to comment.