# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python (htrc)
#     language: python
#     name: htrc
# ---

# In the Hathi Trust case, it's useful to access Ids by their prefixes, as identified by a separator

import SRP
import tempfile
import numpy as np
from pathlib import Path 

# %load_ext autoreload
# %autoreload 2

with tempfile.TemporaryDirectory() as dir:
    fout = SRP.Vector_file(Path(dir, "out.bin"), mode = "a", dims = 2)
    for i in range(3):
        for j in range(5):
            fout.add_row(f"file_{i}-part-{j}", np.array([i, j], '<f4'))
    fout.close()
    newview = SRP.Vector_file(Path(dir, "out.bin"), mode = "a", dims = 2)
    for k, v in newview.find_prefix("file_1", "-"):
        print((k, v))
    newview.add_row('file_100-part_302', np.array([100, 302], '<f4'))
    print(newview.find_prefix("file_100"))

np.float32(1)



StarcoderdataJupyterScriptsDedupFiltered