Skip to content

Commit

Permalink
[processing] fixed frequency algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
volaya committed Jul 12, 2014
1 parent e536905 commit f5b84ca
Showing 1 changed file with 4 additions and 5 deletions.
Expand Up @@ -8,16 +8,16 @@
from processing.core.TableWriter import TableWriter
from collections import defaultdict

layer = processing.getObject(input)
layer = processing.getObject(Input)
inputFields = layer.pendingFields()
fieldIdxs = []
fields = fields.split(',')
fields = Fields.split(',')
for f in fields:
idx = inputFields.indexFromName(f)
if idx == -1:
raise GeoAlgorithmExecutionException('Field not found:' + f)
fieldIdxs.append(idx)
writer = TableWriter(output, None, fields + ['FREQ'])
writer = TableWriter(Output, None, fields + ['FREQ'])

counts = {}
feats = processing.features(layer)
Expand All @@ -26,8 +26,7 @@
for i, feat in enumerate(feats):
progress.setPercentage(int(100 * i / nFeats))
attrs = feat.attributes()
clazz = tuple([attrs[idx] for idx in fieldIdxs])
print clazz
clazz = tuple([attrs[idx] for idx in fieldIdxs])
counts[clazz] += 1

for c in counts:
Expand Down

0 comments on commit f5b84ca

Please sign in to comment.