Close custody main-review checks for named B0 units and coordinate scaling

This commit is contained in:
Frank14f committed 2026-11-15 16:12:22 +08:00
1 parent 6e4d991d78
commit 522ee84f6a
7 files changed
+233 -7

No files matched your search

+15 -1
View File
@@ -9,6 +9,8 @@ from freeze_g1_components import sha
from s2_custody_common import checked,prediction_inputs,verify_prediction_index
from s2_custody_statistics import six_region,kendall_pairs,last_location,part_metrics,component_values,contrast
from run_s2_custody_score import decode_gate
from s2_models.features import BASE_COLUMNS,R2_COLUMNS,base_features
from s2_models.objectives import b0_seconds
def roster():
@@ -91,12 +93,24 @@ class Acceptance(unittest.TestCase):
np.save(root/'base.npy',base);np.savez(root/'r2.npz',features=x)
np.savez(root/'queries.npz',eligible_s2=[True,False,True],anchor_ids=[0,1,2],raw_node_ids=[10,11,12],
multiplicity=[2,1,3],g=np.ones((3,2)),edge_summary=np.ones((3,4)),near_wall=[True,False,False])
(root/'result.json').write_text(json.dumps(dict(base_columns=list(BASE_COLUMNS),r2=dict(columns=list(R2_COLUMNS)))))
row=dict(nodes=3,preparation=dict(preparation_root=str(root),t_set=.4,
output_sha256={p.name:sha(p) for p in root.iterdir()}))
result_sha256=sha(root/'result.json'),output_sha256={p.name:sha(p) for p in root.iterdir()}))
original=np.load;paths=[]
def audit(path,**kwargs):paths.append(Path(path).name);return original(path,**kwargs)
with patch('s2_custody_common.np.load',side_effect=audit):d=prediction_inputs(row)
self.assertEqual(set(paths),{'base.npy','r2.npz','queries.npz'});np.testing.assert_array_equal(d['raw_ids'],[10,12])
metadata=json.loads((root/'result.json').read_text());metadata['r2']['columns'][0]='wrong'
(root/'result.json').write_text(json.dumps(metadata));row['preparation']['result_sha256']=sha(root/'result.json')
with self.assertRaises(ValueError):prediction_inputs(row)
def test_named_B0_units_and_centred_coordinates_over_Rg(self):
self.assertEqual(R2_COLUMNS[0],'Vf');np.testing.assert_array_equal(b0_seconds([0,.25,1],4),[0,1,4])
x=np.array([[2.,4.,6.],[6.,10.,14.]])
base=base_features(x,[1,2],[0,1],[2,4,6],[1,2,3],2,10,1,4)
self.assertEqual(BASE_COLUMNS[:3],('x_star','y_star','z_star'))
np.testing.assert_array_equal(base[:,:3],(x-[1,2,3])/2)
self.assertEqual(last_location([1,2],[2,1],[0,1],base[:,:3]),np.linalg.norm(x[1]-x[0])/2)
def test_frozen_real_metadata_denominators_no_label_read(self):
# Only immutable JSON membership/roster metadata, never geometry or targets.