Download tests/test_hf_decoder_memory.py from StarAtNyte1/beam-boot: direct link, hf CLI and curl.
- Browser
- Download file 604 Bytes
-
https://huggingface.co/StarAtNyte1/beam-boot/resolve/main/tests/test_hf_decoder_memory.py
- Command line
-
hf download hf://StarAtNyte1/beam-boot/tests/test_hf_decoder_memory.py
-
curl -L -o test_hf_decoder_memory.py https://huggingface.co/StarAtNyte1/beam-boot/resolve/main/tests/test_hf_decoder_memory.py
604 Bytes
| import random | |
| import unittest | |
| from beamboot.hf_decoder_memory import DecoderMemory | |
| class DecoderMemoryTests(unittest.TestCase): | |
| def test_reads_and_overwrites(self): | |
| memory = DecoderMemory(max_writes=64) | |
| rng = random.Random(771) | |
| reference = [0] * 16 | |
| for _ in range(64): | |
| address, value = rng.randrange(16), rng.randrange(16) | |
| memory.write(address, value) | |
| reference[address] = value | |
| self.assertEqual(memory.read(address), value) | |
| for address in range(16): self.assertEqual(memory.read(address), reference[address]) | |