Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
faiss
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
faiss
Commits
cd884114
Commit
cd884114
authored
Feb 23, 2018
by
Ailing
Committed by
Matthijs Douze
Feb 23, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make tests compatible with py3 (#348)
parent
0c482e54
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
8 deletions
+9
-8
test_build_blocks.py
tests/test_build_blocks.py
+2
-2
test_index_composite.py
tests/test_index_composite.py
+7
-6
No files found.
tests/test_build_blocks.py
View file @
cd884114
...
...
@@ -144,7 +144,7 @@ class TestException(unittest.TestCase):
try
:
# an unsupported operation for IndexFlat
index
.
add_with_ids
(
a
,
b
)
except
RuntimeError
,
e
:
except
RuntimeError
as
e
:
assert
'add_with_ids not implemented'
in
str
(
e
)
else
:
assert
False
,
'exception did not fire???'
...
...
@@ -153,7 +153,7 @@ class TestException(unittest.TestCase):
try
:
faiss
.
index_factory
(
12
,
'IVF256,Flat,PQ8'
)
except
RuntimeError
,
e
:
except
RuntimeError
as
e
:
assert
'could not parse'
in
str
(
e
)
else
:
assert
False
,
'exception did not fire???'
...
...
tests/test_index_composite.py
View file @
cd884114
...
...
@@ -12,6 +12,7 @@ import numpy as np
import
unittest
import
faiss
import
os
import
tempfile
def
get_dataset_2
(
d
,
nb
,
nt
,
nq
):
"""A dataset that is not completely random but still challenging to
...
...
@@ -48,26 +49,26 @@ class TestRemove(unittest.TestCase):
filename
=
None
if
ondisk
:
filename
=
os
.
tmpnam
()
filename
=
tempfile
.
mkstemp
()[
1
]
invlists
=
faiss
.
OnDiskInvertedLists
(
index1
.
nlist
,
index1
.
code_size
,
filename
)
index1
.
replace_invlists
(
invlists
)
index1
.
add
(
xb
[:
nb
/
2
])
index1
.
add
(
xb
[:
int
(
nb
/
2
)
])
index2
=
faiss
.
IndexIVFFlat
(
quantizer
,
d
,
20
)
assert
index2
.
is_trained
index2
.
add
(
xb
[
nb
/
2
:])
index2
.
add
(
xb
[
int
(
nb
/
2
)
:])
Dref
,
Iref
=
index1
.
search
(
xq
,
10
)
index1
.
merge_from
(
index2
,
nb
/
2
)
index1
.
merge_from
(
index2
,
int
(
nb
/
2
)
)
assert
index1
.
ntotal
==
nb
index1
.
remove_ids
(
faiss
.
IDSelectorRange
(
nb
/
2
,
nb
))
index1
.
remove_ids
(
faiss
.
IDSelectorRange
(
int
(
nb
/
2
)
,
nb
))
assert
index1
.
ntotal
==
nb
/
2
assert
index1
.
ntotal
==
int
(
nb
/
2
)
Dnew
,
Inew
=
index1
.
search
(
xq
,
10
)
assert
np
.
all
(
Dnew
==
Dref
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment