@@ -43,7 +43,7 @@ class AbstractFit(ABC):
4343 def __init__ (self , grid : Grid ):
4444 ns = collect_exponents (grid )
4545 self .grid = grid
46- self .mesh = compute_mesh (grid )
46+ self .mesh = unit_mesh (grid )
4747 self .exponents = ns
4848 self .pinv = pinv (self )
4949
@@ -104,7 +104,15 @@ def scale(x, grid: Grid):
104104 return (x - grid .lower ) * 2 / grid .size - 1
105105
106106
107- def compute_mesh (grid ):
107+ def compute_mesh (grid : Grid ):
108+ """
109+ Returns a dense mesh with the same shape and domain as `grid`.
110+ """
111+ mesh = unit_mesh (grid )
112+ return (mesh + 1 ) / 2 * grid .size + grid .lower
113+
114+
115+ def unit_mesh (grid : Grid ):
108116 """
109117 Returns a dense mesh with the same shape as `grid`, but on the hypercube [-1, 1]ⁿ,
110118 where `n` is the dimensionality of `grid`. The resulting mesh is Chebyshev-distributed
@@ -224,7 +232,7 @@ def pinv(model: SpectralSobolev1Fit): # noqa: F811 # pylint: disable=C0116,E010
224232def build_fitter (model : SpectralGradientFit ):
225233 """
226234 Returns a function which takes an approximation `dy` to the gradient
227- of a function `f` evaluated over the set `x = compute_mesh (model.grid)`,
235+ of a function `f` evaluated over the set `x = unit_mesh (model.grid)`,
228236 and returns a `fun: Fun` object which approximates `f` over
229237 the domain [-1, 1]ⁿ.
230238 """
@@ -253,7 +261,7 @@ def fit(dy):
253261def build_fitter (model : SpectralSobolev1Fit ): # noqa: F811 # pylint: disable=C0116,E0102
254262 """
255263 Returns a function which takes approximations `y` and dy` to a function
256- `f` and its gradient evaluated over the set `x = compute_mesh (model.grid)`,
264+ `f` and its gradient evaluated over the set `x = unit_mesh (model.grid)`,
257265 and in turn returns a `fun: Fun` object which approximates `f` over
258266 the domain [-1, 1]ⁿ.
259267 """
0 commit comments