Replace os.tempnam with tempfile for python3 (#537)

os.tempnam is eliminated in python3.
Used tempfile.NamedTemporaryFile().name instead.
This is also valid for python2.7.
pull/449/merge
Yohei Kikuta 2018-07-24 17:25:40 +09:00 committed by Matthijs Douze
parent 2dc30e14cf
commit 67c6506bcc
1 changed files with 3 additions and 2 deletions

View File

@ -12,6 +12,7 @@ import numpy as np
import unittest
import faiss
import os
import tempfile
def make_binary_dataset(d, nb, nt, nq):
assert d % 8 == 0
@ -37,7 +38,7 @@ class TestBinaryFlat(unittest.TestCase):
index.add(self.xb)
D, I = index.search(self.xq, 3)
tmpnam = os.tempnam()
tmpnam = tempfile.NamedTemporaryFile().name
try:
faiss.write_index_binary(index, tmpnam)
@ -74,7 +75,7 @@ class TestBinaryIVF(unittest.TestCase):
index.add(self.xb)
D, I = index.search(self.xq, 3)
tmpnam = os.tempnam()
tmpnam = tempfile.NamedTemporaryFile().name
try:
faiss.write_index_binary(index, tmpnam)