Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Porting to Python3. #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions example_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
vds.RemoveVar(vds.FindVariable("wifi_usage"))

vdsmatch = DSNetworkMatch(learnedTANNetwork)
print vdsmatch.attachDataset(vds)
print(vdsmatch.attachDataset(vds))

wifi_usage_node = learnedTANNetwork.FindNode("wifi_usage")
learnedTANNetwork.ClearAllEvidence()
Expand All @@ -46,10 +46,10 @@
diff = float(validation_y[i]) - prob
sum_of_squares += diff*diff

print sqrt(sum_of_squares)
print(sqrt(sum_of_squares))
///

print vdsmatch.attachDataset(tds)
print(vdsmatch.attachDataset(tds))
train_y = np.array(train_set.wifi_usage=='s1_below_0', dtype=np.int8)
for i in range(len(train_y)):
vdsmatch.enterEvidenceFromDatasetRow(i)
Expand All @@ -59,7 +59,7 @@
diff = float(train_y[i]) - prob
sum_of_squares += diff*diff

print sqrt(sum_of_squares)
print(sqrt(sum_of_squares))
///
ds.RemoveVar(ds.FindVariable("wifi_usage"))
///
Expand Down
18 changes: 9 additions & 9 deletions example_code2.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@
for i in range(0,20):
sa2.SetString(i, "Alles klar %d" % (i))

print sa2.Subscript(10)
print(sa2.Subscript(10))
# Basic id array functionality
ia2 = DSL_idArray(20,10)

for i in range(0,20):
ia2.SetString(i, "AllesKlar%d" % (i))

print ia2.Subscript(10)
print(ia2.Subscript(10))
ia2.SetString(4, "Alles Klar %d" % (4))

print ia2.Subscript(4)
print(ia2.Subscript(4))
ar = toDSL_intArray([1,2,3])
ari = intArray.frompointer(ar.Items())

Expand Down Expand Up @@ -119,24 +119,24 @@
ds2 = DSL_dataset()
ds2.ReadFile('/data/fast/ltm_wifi_test/NISLTM/train_set.csv')
for name in ds2.GetStateNames(ds2.FindVariable("domain_content")):
print name
print(name)

for name in vds.GetStateNames(vds.FindVariable("domain_content")):
print name
print(name)

x = DSNetworkMatch(learnedTANNetwork)
print x.attachDataset(vds)
print(x.attachDataset(vds))
wifi_usage_node = learnedTANNetwork.FindNode("wifi_usage")
learnedTANNetwork.ClearAllEvidence()
learnedTANNetwork.UpdateBeliefs()
va = doubleArray.frompointer(learnedTANNetwork.GetNode(wifi_usage_node).Value().GetMatrix().GetItems().Items())
print va[0]
print(va[0])

for i in range(10):
x.enterEvidenceFromDatasetRow(21*i)
learnedTANNetwork.UpdateBeliefs()
print va[0]
print(va[0])

outc = ndef.GetOutcomesNames()
for i in range(outc.GetSize()):
print outc.Subscript(i)
print(outc.Subscript(i))
2 changes: 1 addition & 1 deletion test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

net = pysmile.DSL_network()

print "OK"
print("OK")