Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
daxpryce committed Oct 24, 2024
1 parent 5f81d3d commit a3c0685
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions python/tests/test_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ def test_in_mem(self):
def test_memmap(self):
expected = random_vectors(10_000, 100, dtype=np.float32)
with vectors_as_temp_file(expected) as vecs_file:
vecs_files_copy = Path(tempfile.mkstemp())
try:
shutil.copyfile(vecs_file, str(vecs_file_copy))
with tempfile.NamedTemporaryFile(delete=False) as vecs_file_copy:
shutil.copyfile(vecs_file, vecs_file_copy.name)
actual = dap.vectors_from_file(
vecs_file,
dtype=np.float32,
Expand All @@ -37,15 +36,13 @@ def test_memmap(self):
# that's why we made a copy of the file itself and are using the copy here to test
# the read+append(inmem)
actual = dap.vectors_from_file(
str(vecs_file_copy),
vecs_file_copy.name,
dtype=np.float32,
use_memmap=True,
mode="r+"
)
self.assertTrue((expected == actual).all(), f"{expected == actual}\n{expected}\n{actual}")
finally:
if vecs_file_copy.exists():
vecs_file_copy.unlink()
vecs_file_copy.unlink()


if __name__ == '__main__':
Expand Down

0 comments on commit a3c0685

Please sign in to comment.