Skip to content

Commit 00be8c4

Browse files
author
Feras A. Saad
committed
User iteritems() and itervalues() for iterating over dictionaries.
1 parent 3ef4bf8 commit 00be8c4

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/backends/cgpm_backend.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,7 @@ def _json_ready_model(self, state, name_map):
955955
view_indices = sorted(state.views.keys())
956956
# state.Zv() is a column partition given as {colnum: viewnum, ...}
957957
column_partition = [
958-
[name_map[colno] for colno, current_view_index in state.Zv().items()
958+
[name_map[colno] for colno, current_view_index in state.Zv().iteritems()
959959
if current_view_index==view_index]
960960
for view_index in view_indices
961961
]
@@ -975,10 +975,10 @@ def _json_ready_model(self, state, name_map):
975975
[
976976
sorted([
977977
rowid
978-
for (rowid, current_cluster_index) in state.views[view_index].Zr().items()
978+
for (rowid, current_cluster_index) in state.views[view_index].Zr().iteritems()
979979
if current_cluster_index==cluster_index
980980
])
981-
for cluster_index in sorted(set(state.views[view_index].Zr().values()))
981+
for cluster_index in sorted(set(state.views[view_index].Zr().itervalues()))
982982
]
983983
for view_index in view_indices
984984
]
@@ -1000,7 +1000,7 @@ def _json_ready_model(self, state, name_map):
10001000
def _json_ready_categories(self, bdb, population_id, generator_id, stattypes):
10011001
name_map = {
10021002
k:v
1003-
for k, v in core.bayesdb_colno_to_variable_names(bdb, population_id, generator_id).items()
1003+
for k, v in core.bayesdb_colno_to_variable_names(bdb, population_id, generator_id).iteritems()
10041004
if stattypes[v] == 'nominal'
10051005
}
10061006
# All categories for all categorical variables
@@ -1011,7 +1011,7 @@ def _json_ready_categories(self, bdb, population_id, generator_id, stattypes):
10111011
# Collate categories by variable
10121012
return {
10131013
name: [item[2] for item in raw_categories if item[0]==colno]
1014-
for colno,name in name_map.items()
1014+
for colno,name in name_map.iteritems()
10151015
}
10161016

10171017
def _unique_rowid(self, rowids):

0 commit comments

Comments
 (0)