Files
MeltMind/tools/test_phase2_gate_outcome_features.py
T

21 lines
1.2 KiB
Python

import unittest
import numpy as np
from test_gre24_features import box
from gre24_features_v2 import features,gate_nodes
from phase2_gate_outcome_features import recompute
class FixedAlgorithm(unittest.TestCase):
def test_same_gate_reproduces_full_original_feature_builder(self):
x,t=box();raw=np.arange(len(x));gate=x[0];old,meta=features(x,t,raw,gate)
source,_=gate_nodes(x,raw,gate);new,_=recompute(x,t,old['Dw'],source)
for name in ['features','Di','Df','Vf']:np.testing.assert_array_equal(new[name],old[name])
def test_different_sealed_gate_reproduces_original_marked_gate(self):
x,t=box();raw=np.arange(len(x));gate=x[0];sources=np.array([0,1],dtype=np.int64)
old,meta=features(x,t,raw,gate,marked_gate=sources);new,_=recompute(x,t,old['Dw'],sources)
for name in ['features','Di','Df','Vf']:np.testing.assert_array_equal(new[name],old[name])
def test_gate_independent_wall_columns_unchanged(self):
x,t=box();raw=np.arange(len(x));old,meta=features(x,t,raw,x[0]);new,_=recompute(x,t,old['Dw'],np.array([len(x)-1]))
np.testing.assert_array_equal(new['features'][:,8:13],old['features'][:,8:13])
if __name__=='__main__':unittest.main()