-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGDSJoin_test_example.py
More file actions
39 lines (23 loc) · 929 Bytes
/
GDSJoin_test_example.py
File metadata and controls
39 lines (23 loc) · 929 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import csv
import numpy as np
import pandas as pd
#load the GDS-Join Python library
import gdsjoingpu as dssj
def getColumn(filename, column):
results = csv.reader(open(filename), delimiter=",")
# next(results, None) # skip the headers
return [result[column] for result in results]
if __name__ == "__main__":
#parameters
fname="test_dat.txt"
df = pd.read_csv(fname, delimiter=',', header=None)
#flatten data to a list which is required by the library
dataset = df.values.flatten().tolist()
epsilon = 1.0
verbose=True #True/False --- this is the C output from the shared library
dtype="float"
numdim=2
numNeighbors, neighborTable = dssj.gdsjoin(dataset, epsilon, numdim, dtype, verbose)
#this is only used so that we can run multiple examples at once and surpress the C stdout
if(verbose==False):
dssj.redirect_stdout()