Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
else:
for id, data in enumerate(read_data('sample_dataset.txt')):
pos = nmslib.addDataPoint(index, id, data)
if id != pos:
print('id %s != pos %s' % (id, pos))
sys.exit(1)
end = time.time()
print('added data in %s secs' % (end - start))
print('Let\'s print a few data entries')
print('We have added %d data points' % nmslib.getDataPointQty(index))
print("Distance between points (0,0) " + str(nmslib.getDistance(index, 0, 0)));
print("Distance between points (1,1) " + str(nmslib.getDistance(index, 1, 1)));
print("Distance between points (0,1) " + str(nmslib.getDistance(index, 0, 1)));
print("Distance between points (1,0) " + str(nmslib.getDistance(index, 1, 0)));
for i in range(0,min(MAX_PRINT_QTY,nmslib.getDataPointQty(index))):
print(nmslib.getDataPoint(index, i))
print('Let\'s invoke the index-build process')
index_param = ['NN=17', 'efConstruction=50', 'indexThreadQty=4']
query_time_param = ['efSearch=50']
nmslib.createIndex(index, index_param)
print('The index is created')
nmslib.setQueryTimeParams(index,query_time_param)
print('Query time parameters are set')
positions = nmslib.addDataPointBatch(index, np.arange(len(data), dtype=np.int32), data)
else:
for id, data in enumerate(read_data('sample_dataset.txt')):
pos = nmslib.addDataPoint(index, id, data)
if id != pos:
print('id %s != pos %s' % (id, pos))
sys.exit(1)
end = time.time()
print('added data in %s secs' % (end - start))
print('Let\'s print a few data entries')
print('We have added %d data points' % nmslib.getDataPointQty(index))
print("Distance between points (0,0) " + str(nmslib.getDistance(index, 0, 0)));
print("Distance between points (1,1) " + str(nmslib.getDistance(index, 1, 1)));
print("Distance between points (0,1) " + str(nmslib.getDistance(index, 0, 1)));
print("Distance between points (1,0) " + str(nmslib.getDistance(index, 1, 0)));
for i in range(0,min(MAX_PRINT_QTY,nmslib.getDataPointQty(index))):
print(nmslib.getDataPoint(index, i))
print('Let\'s invoke the index-build process')
index_param = ['NN=17', 'efConstruction=50', 'indexThreadQty=4']
query_time_param = ['efSearch=50']
nmslib.createIndex(index, index_param)
print('The index is created')
nmslib.setQueryTimeParams(index,query_time_param)
print('data.shape', data.shape)
positions = nmslib.addDataPointBatch(index, np.arange(len(data), dtype=np.int32), data)
else:
for id, data in enumerate(read_data('sample_dataset.txt')):
pos = nmslib.addDataPoint(index, id, data)
if id != pos:
print('id %s != pos %s' % (id, pos))
sys.exit(1)
end = time.time()
print('added data in %s secs' % (end - start))
print('Let\'s print a few data entries')
print('We have added %d data points' % nmslib.getDataPointQty(index))
print("Distance between points (0,0) " + str(nmslib.getDistance(index, 0, 0)));
print("Distance between points (1,1) " + str(nmslib.getDistance(index, 1, 1)));
print("Distance between points (0,1) " + str(nmslib.getDistance(index, 0, 1)));
print("Distance between points (1,0) " + str(nmslib.getDistance(index, 1, 0)));
for i in range(0,min(MAX_PRINT_QTY,nmslib.getDataPointQty(index))):
print(nmslib.getDataPoint(index, i))
print('Let\'s invoke the index-build process')
index_param = ['NN=17', 'efConstruction=50', 'indexThreadQty=4']
query_time_param = ['efSearch=50']
nmslib.createIndex(index, index_param)
print('The index is created')
nmslib.setQueryTimeParams(index,query_time_param)
method_name,
nmslib.DataType.OBJECT_AS_STRING,
nmslib.DistType.INT)
if batch:
print('DATA_STRS', DATA_STRS)
positions = nmslib.addDataPointBatch(index, np.arange(len(DATA_STRS), dtype=np.int32), DATA_STRS)
else:
for id, data in enumerate(DATA_STRS):
nmslib.addDataPoint(index, id, data)
print('Let\'s print a few data entries')
print('We have added %d data points' % nmslib.getDataPointQty(index))
print("Distance between points (0,0) " + str(nmslib.getDistance(index, 0, 0)));
print("Distance between points (1,1) " + str(nmslib.getDistance(index, 1, 1)));
print("Distance between points (0,1) " + str(nmslib.getDistance(index, 0, 1)));
print("Distance between points (1,0) " + str(nmslib.getDistance(index, 1, 0)));
for i in range(0,min(MAX_PRINT_QTY,nmslib.getDataPointQty(index))):
print(nmslib.getDataPoint(index,i))
print('Let\'s invoke the index-build process')
index_param = ['NN=17', 'efConstruction=50', 'indexThreadQty=4']
query_time_param = ['efSearch=50']
nmslib.createIndex(index, index_param)
nmslib.setQueryTimeParams(index, query_time_param)
print('Query time parameters are set')
nmslib.DistType.INT)
if batch:
print('DATA_STRS', DATA_STRS)
positions = nmslib.addDataPointBatch(index, np.arange(len(DATA_STRS), dtype=np.int32), DATA_STRS)
else:
for id, data in enumerate(DATA_STRS):
nmslib.addDataPoint(index, id, data)
print('Let\'s print a few data entries')
print('We have added %d data points' % nmslib.getDataPointQty(index))
print("Distance between points (0,0) " + str(nmslib.getDistance(index, 0, 0)));
print("Distance between points (1,1) " + str(nmslib.getDistance(index, 1, 1)));
print("Distance between points (0,1) " + str(nmslib.getDistance(index, 0, 1)));
print("Distance between points (1,0) " + str(nmslib.getDistance(index, 1, 0)));
for i in range(0,min(MAX_PRINT_QTY,nmslib.getDataPointQty(index))):
print(nmslib.getDataPoint(index,i))
print('Let\'s invoke the index-build process')
index_param = ['NN=17', 'efConstruction=50', 'indexThreadQty=4']
query_time_param = ['efSearch=50']
nmslib.createIndex(index, index_param)
nmslib.setQueryTimeParams(index, query_time_param)
print('Query time parameters are set')
print("Results for the freshly created index:")
space_param,
method_name,
nmslib.DataType.OBJECT_AS_STRING,
nmslib.DistType.INT)
if batch:
print('DATA_STRS', DATA_STRS)
positions = nmslib.addDataPointBatch(index, np.arange(len(DATA_STRS), dtype=np.int32), DATA_STRS)
else:
for id, data in enumerate(DATA_STRS):
nmslib.addDataPoint(index, id, data)
print('Let\'s print a few data entries')
print('We have added %d data points' % nmslib.getDataPointQty(index))
print("Distance between points (0,0) " + str(nmslib.getDistance(index, 0, 0)));
print("Distance between points (1,1) " + str(nmslib.getDistance(index, 1, 1)));
print("Distance between points (0,1) " + str(nmslib.getDistance(index, 0, 1)));
print("Distance between points (1,0) " + str(nmslib.getDistance(index, 1, 0)));
for i in range(0,min(MAX_PRINT_QTY,nmslib.getDataPointQty(index))):
print(nmslib.getDataPoint(index,i))
print('Let\'s invoke the index-build process')
index_param = ['NN=17', 'efConstruction=50', 'indexThreadQty=4']
query_time_param = ['efSearch=50']
nmslib.createIndex(index, index_param)
nmslib.setQueryTimeParams(index, query_time_param)
print('Query time parameters are set')
nmslib.DataType.OBJECT_AS_STRING,
nmslib.DistType.INT)
if batch:
print('DATA_STRS', DATA_STRS)
positions = nmslib.addDataPointBatch(index, np.arange(len(DATA_STRS), dtype=np.int32), DATA_STRS)
else:
for id, data in enumerate(DATA_STRS):
nmslib.addDataPoint(index, id, data)
print('Let\'s print a few data entries')
print('We have added %d data points' % nmslib.getDataPointQty(index))
print("Distance between points (0,0) " + str(nmslib.getDistance(index, 0, 0)));
print("Distance between points (1,1) " + str(nmslib.getDistance(index, 1, 1)));
print("Distance between points (0,1) " + str(nmslib.getDistance(index, 0, 1)));
print("Distance between points (1,0) " + str(nmslib.getDistance(index, 1, 0)));
for i in range(0,min(MAX_PRINT_QTY,nmslib.getDataPointQty(index))):
print(nmslib.getDataPoint(index,i))
print('Let\'s invoke the index-build process')
index_param = ['NN=17', 'efConstruction=50', 'indexThreadQty=4']
query_time_param = ['efSearch=50']
nmslib.createIndex(index, index_param)
nmslib.setQueryTimeParams(index, query_time_param)
print('Query time parameters are set')
print("Results for the freshly created index:")