Skip to content

Commit

Permalink
Update Python tests and tutos
Browse files Browse the repository at this point in the history
  • Loading branch information
relf committed Mar 27, 2024
1 parent 96a8ddf commit 497af7e
Show file tree
Hide file tree
Showing 6 changed files with 1,937 additions and 1,746 deletions.
15 changes: 3 additions & 12 deletions doc/Egor_Tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,10 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "1504e619-5775-42d3-8f48-7339272303ec",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: egobox in d:\\rlafage\\miniconda3\\lib\\site-packages (0.12.0)\n",
"Note: you may need to restart the kernel to use updated packages.\n"
]
}
],
"outputs": [],
"source": [
"%pip install egobox"
]
Expand Down Expand Up @@ -753,7 +744,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.11.5"
}
},
"nbformat": 4,
Expand Down
959 changes: 399 additions & 560 deletions doc/Gpx_MaunaLoaCO2.ipynb

Large diffs are not rendered by default.

1,886 changes: 1,049 additions & 837 deletions doc/Gpx_Tutorial.ipynb

Large diffs are not rendered by default.

803 changes: 476 additions & 327 deletions doc/SparseGpx_Tutorial.ipynb

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions python/egobox/examples/kriging.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
num = 100
x = np.linspace(0.0, 4.0, num).reshape((-1, 1))

y = gpx.predict_values(x)
y = gpx.predict(x)
# estimated variance
s2 = gpx.predict_variances(x)
s2 = gpx.predict_var(x)

fig, axs = plt.subplots(1)

Expand Down
16 changes: 8 additions & 8 deletions python/egobox/tests/test_gpmix.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ def test_gpx_kriging(self):
print(f"gpx.likelihood = {gpx.likelihoods()}")

# should interpolate
self.assertAlmostEqual(1.0, gpx.predict_values(np.array([[1.0]])).item())
self.assertAlmostEqual(0.0, gpx.predict_variances(np.array([[1.0]])).item())
self.assertAlmostEqual(1.0, gpx.predict(np.array([[1.0]])).item())
self.assertAlmostEqual(0.0, gpx.predict_var(np.array([[1.0]])).item())

# check a point not too far from a training point
self.assertAlmostEqual(
1.1163, gpx.predict_values(np.array([[1.1]])).item(), delta=1e-3
1.1163, gpx.predict(np.array([[1.1]])).item(), delta=1e-3
)
self.assertAlmostEqual(
0.0, gpx.predict_variances(np.array([[1.1]])).item(), delta=1e-3
0.0, gpx.predict_var(np.array([[1.1]])).item(), delta=1e-3
)

def test_gpx_save_load(self):
Expand All @@ -46,15 +46,15 @@ def test_gpx_save_load(self):
os.remove(filename)

# should interpolate
self.assertAlmostEqual(1.0, gpx2.predict_values(np.array([[1.0]])).item())
self.assertAlmostEqual(0.0, gpx2.predict_variances(np.array([[1.0]])).item())
self.assertAlmostEqual(1.0, gpx2.predict(np.array([[1.0]])).item())
self.assertAlmostEqual(0.0, gpx2.predict_var(np.array([[1.0]])).item())

# check a point not too far from a training point
self.assertAlmostEqual(
1.1163, gpx2.predict_values(np.array([[1.1]])).item(), delta=1e-3
1.1163, gpx2.predict(np.array([[1.1]])).item(), delta=1e-3
)
self.assertAlmostEqual(
0.0, gpx2.predict_variances(np.array([[1.1]])).item(), delta=1e-3
0.0, gpx2.predict_var(np.array([[1.1]])).item(), delta=1e-3
)


Expand Down

0 comments on commit 497af7e

Please sign in to comment.