From 43ceab12524df787fdbfeea47232bfe94c66a885 Mon Sep 17 00:00:00 2001 From: patnr Date: Tue, 5 Sep 2023 13:40:31 +0200 Subject: [PATCH] Lint --- TPFA_ResSim/__init__.py | 3 ++- TPFA_ResSim/grid.py | 12 +++++++----- pyproject.toml | 4 ++++ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/TPFA_ResSim/__init__.py b/TPFA_ResSim/__init__.py index 36c0a96..a8daa13 100644 --- a/TPFA_ResSim/__init__.py +++ b/TPFA_ResSim/__init__.py @@ -75,8 +75,9 @@ def __setattr__(self, key, val): Values should be betwen `0` and `Lx` or `Ly`. - .. warning:: The wells get co-located with grid nodes, not distributed over nearby ones. + .. warning:: The wells get co-located with grid nodes, ref `xy2sub`. This is a design choice, not a mathematical necessity. + An alternative would be to distribute them over nearby nodes. """ prod_xy: np.ndarray = None """Like `inj_xy`, but for producing wells.""" diff --git a/TPFA_ResSim/grid.py b/TPFA_ResSim/grid.py index c5287c6..c007724 100644 --- a/TPFA_ResSim/grid.py +++ b/TPFA_ResSim/grid.py @@ -38,10 +38,6 @@ class Grid2D: You can compute cell boundaries (i.e. non-central nodes) by adding or subtracting `hx`/2 and `hy`/2 (i.e. you will miss either boundary at 0 or `Lx` or `Ly`). - .. warning:: `xy2sub` and `xy2ind` *round* to nearest cell center (they are not injective). - The alternative would be to return some kind - of interpolation weights distributing `(x, y)` over multiple nodes. - Test of round-trip capability of grid mapping computations: >>> ij = (0, 4) >>> grid.xy2sub(X[ij], Y[ij]) == ij @@ -108,7 +104,13 @@ def ind2sub(self, ind): return np.asarray([ix, iy]) def xy2sub(self, x, y): - """Convert physical coordinate tuple to `(ix, iy)`, ix ∈ {0, ..., Nx-1}.""" + """Convert physical coordinate tuple to `(ix, iy)`, ix ∈ {0, ..., Nx-1}. + + .. warning:: `xy2sub` and `xy2ind` *round* to nearest cell center. + I.e. they are not injective. + The alternative would be to return some kind + of interpolation weights distributing `(x, y)` over multiple nodes. + """ x = np.asarray(x) y = np.asarray(y) # Don't silence errors! Validation is useful in optimisation (e.g.) diff --git a/pyproject.toml b/pyproject.toml index c55ce59..4882b61 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,6 +54,10 @@ pycodestyle = ["+*", "-E731", # don't assign lambda ] +[tool.flakeheaven.exceptions."tests/test_fig6.py"] +pycodestyle = ["-E225"] + + ############# # Testing # #############