Add Grok's Jet review tests (5-link sector oracle, axis wrap)
Taken from Grok's inline patch (Slack ts 1792052057.423679); the selector
fix in that patch was already applied in b1cd555. The rotated-tube and
non-circle-wall cases were clipped in transit and are not included.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
aebef52345
commit
508d412e43
@@ -0,0 +1,40 @@
|
||||
"""Grok review cases for claude/jet (test-only; from Grok's inline patch at Slack
|
||||
ts 1792052057.423679). The rotated-tube and non-circle-wall cases were clipped
|
||||
by the Slack reader and are not included yet."""
|
||||
import math
|
||||
import numpy as np
|
||||
from CelerisLab.body.jets import Sector
|
||||
from .test_surface_actuation import circle
|
||||
|
||||
|
||||
def big_scene():
|
||||
from CelerisLab.config import LBMConfig
|
||||
from CelerisLab.body.manager import ObjectManager
|
||||
from CelerisLab.lbm.descriptors import FLUID
|
||||
obj = circle(center=(20., 15.), radius=6.5)
|
||||
cfg = LBMConfig(nx=40, ny=30, viscosity=.1); cfg.validate()
|
||||
flags = ObjectManager.build_flags_for([obj], np.full(40*30, FLUID, np.uint16), nx=40, ny=30, nz=1)
|
||||
links = obj.geometry.build_cut_links(40, 30, domain_flags=flags)
|
||||
hits = np.array([(l.hit_x, l.hit_y) for l in links])
|
||||
fl, dr = obj.get_curved_list(40, 30, cfg.nq, domain_flags=flags)[:2]
|
||||
return hits, np.asarray(fl), np.asarray(dr)
|
||||
|
||||
|
||||
def test_frozen_5_link_sector_oracle_with_edge_margin():
|
||||
hits, fl, dr = big_scene()
|
||||
half = math.radians(5)
|
||||
sel, s = Sector((20., 15.), 0., half, 7.5, 5.5).select(hits)
|
||||
got = sorted((int(f % 40), int(f // 40), int(d)) for f, d in zip(fl[sel], dr[sel]))
|
||||
assert got == sorted([(27, 15, 2), (27, 14, 8), (27, 16, 6), (27, 15, 6), (27, 15, 8)])
|
||||
d = hits - (20., 15.)
|
||||
dth = np.abs(np.arctan2(d[:, 1], d[:, 0]))
|
||||
near = np.hypot(*d.T) < 7.5
|
||||
assert np.all(np.abs(dth[near] - half) >= 1e-3) # no hit within 1e-3 rad of the edge
|
||||
|
||||
|
||||
def test_sector_axis_pi_wraps():
|
||||
hits = np.array([[-1., 1e-3], [-1., -1e-3], [1., 0.]])
|
||||
sel, _ = Sector((0., 0.), math.pi, .01, 2.).select(hits)
|
||||
assert sel.tolist() == [True, True, False]
|
||||
sel, _ = Sector((0., 0.), -math.pi, .01, 2.).select(hits)
|
||||
assert sel.tolist() == [True, True, False]
|
||||
Reference in New Issue
Block a user