Download tests/test_patch_limits.py from LIghtJUNction/LightNest: direct link, hf CLI and curl.
- Browser
- Download file 1.26 kB
-
https://huggingface.co/LIghtJUNction/LightNest/resolve/main/tests/test_patch_limits.py
- Command line
-
hf download hf://LIghtJUNction/LightNest/tests/test_patch_limits.py
-
curl -L -o test_patch_limits.py https://huggingface.co/LIghtJUNction/LightNest/resolve/main/tests/test_patch_limits.py
1.26 kB
| from lightnest.probe_patch_limits import freeze, assess, signed | |
| from lightnest.learned_patch import LearnedPatch | |
| def test_frozen_deterministic_and_reference_oracles(): | |
| entries=freeze(2) | |
| assert entries==freeze(2) | |
| assert len(entries)==24 | |
| for entry in entries: | |
| result=assess(entry,None) | |
| if entry['expected'] is None: | |
| assert result['category']=='unsupported_no_oracle_abstention' | |
| elif entry['family'] in ('negation','keep_unchanged','already_correct'): | |
| assert result['category']=='correct_negative_abstention' | |
| else: | |
| assert result['category']=='positive_abstention' | |
| def test_single_correct_patch_and_negation_damage(): | |
| entries=freeze(1) | |
| for family,wanted in [('single_control','positive_pass'),('negation','negative_destructive_proposal')]: | |
| e=next(x for x in entries if x['family']==family) | |
| binary=bytes.fromhex(e['binary_hex']) | |
| # Only the single ADD in these fixtures can carry opcode 0x33. | |
| offset=next(i+3 for i in range(0,len(binary),4) if binary[i]&127==0x33) | |
| patch=LearnedPatch(offset,binary[offset],binary[offset]^0x40) | |
| assert assess(e,patch)['category']==wanted | |
| def test_signed_wrap(): | |
| assert signed(2**31)==-2**31 | |