From c650f61ea3e4b2938c084e374750a1631f94777d Mon Sep 17 00:00:00 2001 From: ignis Date: Mon, 5 Aug 2019 13:02:24 +0900 Subject: [PATCH] disable pycompact test write to file and ignore .so files --- code/.gitignore | 1 + code/pycompact/pycompact.py | 30 ++++++++++++++++++------------ 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/code/.gitignore b/code/.gitignore index b4e813d..b76dffd 100644 --- a/code/.gitignore +++ b/code/.gitignore @@ -1,3 +1,4 @@ *.o +*.so *.pyc *.ipynb diff --git a/code/pycompact/pycompact.py b/code/pycompact/pycompact.py index 064f0b9..b9d6f3f 100644 --- a/code/pycompact/pycompact.py +++ b/code/pycompact/pycompact.py @@ -215,6 +215,8 @@ def read_data (fname): def validate_trigonometric(): + writeToFile = False + shape = (256, 256, 512) nz, ny, nx = shape @@ -245,24 +247,28 @@ def validate_trigonometric(): Y1[:] = np.sin(1.1 * xx) * np.sin(3.0 * yy) * np.sin(2.0 * zz)[:] true[:] = (1.1 * np.cos(1.1 * xx) * np.sin(3.0 * yy) * np.sin(2.0 * zz))[:] + dY1 = cs.ddx(Y1)[:] - y = np.memmap("phi", dtype=np.float64, mode="w+", shape=cs.shape) - y[:] = Y1[:] - - dydxtrue = np.memmap("dphitrue", dtype=np.float64, mode="w+", shape=cs.shape) - dydxtrue[:] = true[:] + print (dY1.min(), dY1.max()) - dydx = np.memmap("dphi", dtype=np.float64, mode="w+", shape=cs.shape) - dydx[:] = cs.ddx(Y1)[:] + print (true.min(), true.max()) - - print (dydx.min(), dydx.max()) - print (dydxtrue.min(), dydxtrue.max()) - - relerr = (dydx - dydxtrue) / dydxtrue + relerr = (dY1 - true) / true print (np.nanmin(relerr), np.nanmax(relerr)) + + if writeToFile: + y = np.memmap("phi", dtype=np.float64, mode="w+", shape=cs.shape) + y[:] = Y1[:] + + dydxtrue = np.memmap("dphitrue", dtype=np.float64, mode="w+", shape=cs.shape) + dydxtrue[:] = true[:] + + dydx = np.memmap("dphi", dtype=np.float64, mode="w+", shape=cs.shape) + dydx[:] = dY1[:] + + # cs.verify_nonp_coef()