2
# -*- coding: utf-8 -*-
3
#########################################################################################################################################
4
# 2009 CNRS Postdoctorate JFLI
6
# (c) All rights reserved
7
# ###############################################
9
#########################################################################################################################################
10
# Import required objects
11
#########################################################################################################################################
14
from pycvf.core.errors import *
15
from pycvf.core.generic_application import *
16
from pycvf.core.utilities import with_progressbar
18
class DbIdxTester(IndexUsingApplication):
19
class ProgramMetadata(object):
20
name="Index Implementation Tester"
22
author="Bertrand Nouvel bertrand.nouvel@gmail.com"
23
copyright=" COPYRIGHT Bertrand Nouvel - JFLI - CNRS 2010"
28
key=CmdLineString(None,"key","modelpath","specified within the model what should be used as key when indexing","0")
29
value=CmdLineString(None,"value","modelpath","specified within the model what should be used as value when indexing","@")
32
def process(cls,*args, **kwargs):
33
keyval=cls.mdl.resolve_modelpath("0")
34
valueval=cls.mdl.resolve_modelpath("@")
37
keys=cls.mdl.process_path([e[0]],[e[1]],keyval,lambda x:x)
38
values=cls.mdl.process_path([e[0]],[e[1]],valueval,lambda x:x)
39
for c in zip(keys,values):
40
cls.idx.add(c[0],c[1])
51
e=[ idb.next() for i in range(nq) ]
52
keys=cls.mdl.process_path(map(lambda f:f[0],e),map(lambda f:f[1],e),keyval,lambda x:x)
53
keys=numpy.array(keys)
54
l=cls.idx.getitems(keys,nr)
55
if (type(l)==numpy.ndarray):
57
print type(l),type(l[0]),type(l[0][0]), type(l[0][0][0]),type(l[0][0][1])
58
print len(l),len(l[0])
60
assert (type(l)==list) # queries
62
assert (type(l[0])==list) # results
63
assert (len(l[0])<=nr)
64
assert (len(l[0][0])==2)
65
#assert (type(l[0][0])==tuple)
66
xxx=map (lambda y:map(lambda x:(cls.vdb[x[0]],x[1]),y),l)
67
#xxx=map (lambda y:map(lambda x:(cls.vdb[x[0][:]],x[1]),y),l)
72
if __name__=="__main__":
73
DbIdxTester.run(sys.argv[1:])