Commit f9607f00 by René Fritze

### [tests] remove non-negative grid coord assumption

parent 54353a6d
 ... ... @@ -17,8 +17,10 @@ def _scale_tols_if_domain_bad(g, atol=1e-05, rtol=1e-08): # "badly" shaped domains produce excessive errors # same for large differences in absolute coord values bbox = g.bounding_box() scale = 1.0 lower_left, upper_right = bbox[0], bbox[1] magic_downscale = 1e-3 if g.dim == 2: lower_left, upper_right = bbox[0], bbox[1] upper_left = np.array([lower_left[0], upper_right[1]]) lower_right = np.array([lower_left[1], upper_right[0]]) h = np.linalg.norm(upper_left - lower_left) ... ... @@ -26,10 +28,15 @@ def _scale_tols_if_domain_bad(g, atol=1e-05, rtol=1e-08): min_l = min(w, h) max_l = max(w, h) ll, rr = np.linalg.norm(lower_left), np.linalg.norm(upper_right) scale = max(max_l / min_l, abs(rr-ll)*1e-2) if scale > 100: rtol *= scale / 10 atol *= scale / 10 scale = max(max_l / min_l, abs(rr - ll) * magic_downscale) if g.dim == 1: ratio = abs(upper_right) / abs(lower_left) if not np.isfinite(ratio): ratio = abs(upper_right)*magic_downscale scale = max(ratio, abs(upper_right-lower_left)*magic_downscale)[0] if scale > 10: rtol *= scale atol *= scale assert np.isfinite(atol) assert np.isfinite(rtol) return atol, rtol ... ...
 ... ... @@ -16,15 +16,17 @@ from pymor.discretizers.builtin.grids.unstructured import UnstructuredTriangleGr def hy_domain_bounds(draw, grid_type): # domain points are limited to allow their norm2 computations # TODO: allow negative coordinate points max_abs = grid_type.MAX_DOMAIN_WIDTH / 2 min_abs = grid_type.MIN_DOMAIN_WIDTH / 2 domain_point = hyst.floats(allow_infinity=False, allow_nan=False, min_value=min_abs, max_value=max_abs) max_val = grid_type.MAX_DOMAIN_WIDTH / 2 min_val = -grid_type.MAX_DOMAIN_WIDTH / 2 domain_point = hyst.floats(allow_infinity=False, allow_nan=False, allow_subnormal=False, min_value=min_val, max_value=max_val) ll = draw(hyst.tuples(*[domain_point] * grid_type.dim)) def _filter(d): return all(l < r for l, r in zip(ll, d)) and grid_type._check_domain((ll, d)) return (all(l < r and abs(r - l) > grid_type.MIN_DOMAIN_WIDTH for l, r in zip(ll, d)) and grid_type._check_domain((ll, d))) ll = draw(hyst.tuples(*[domain_point] * grid_type.dim)) rr = draw(hyst.tuples(*[domain_point] * grid_type.dim).filter(_filter)) return ll, rr ... ...
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment