Skip to content

Commit

Permalink
test: add test compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
snowyu committed Feb 2, 2024
1 parent 6dfb551 commit 84dc536
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions gguf-py/tests/test_gguf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

class TestGGUFReaderWriter(unittest.TestCase):

def test_rw(self) -> None:
# Example usage with a file
@classmethod
def setUpClass(cls):
gguf_writer = GGUFWriter(model_file, "llama")

# gguf_writer.add_architecture()
Expand All @@ -31,6 +31,7 @@ def test_rw(self) -> None:
gguf_writer.add_kv("tokenizer.ggml.add_bos_token", True)
gguf_writer.add_dict("tokenizer_config", {
"/tokenizer.ggml.bos_token_id:bos_token": None, "/tokenizer.ggml.add_bos_token": None})
gguf_writer.add_array("oldArray", [1, 2, 3])
gguf_writer.add_custom_alignment(64)

tensor1 = np.ones((32,), dtype=np.float32) * 100.0
Expand All @@ -47,6 +48,18 @@ def test_rw(self) -> None:

gguf_writer.close()

def test_rw(self) -> None:
# test compatibility
gguf_reader = GGUFReader(model_file)
self.assertEqual(gguf_reader.alignment, 64)
v = gguf_reader.get_field("oldArray")
self.assertIsNotNone(v)
type, itype = v.getType()
self.assertEqual(type, GGUFValueType.ARRAY)
self.assertEqual(itype, GGUFValueType.INT32)
self.assertListEqual(v.get(), [1,2,3])

def test_rw_ex(self) -> None:
gguf_reader = GGUFReader(model_file)
self.assertEqual(gguf_reader.alignment, 64)

Expand Down
Binary file modified tests/test_writer.gguf
Binary file not shown.

0 comments on commit 84dc536

Please sign in to comment.