Skip to content

Commit e9df8de

Browse files
committed
The summarize_attrib wps will not return NaNs.
1 parent 6dfbf72 commit e9df8de

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

scripts/wps/summarize_attrib.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from org.apache.commons.math3.stat.descriptive import DescriptiveStatistics
77
from org.apache.commons.math3.stat.descriptive import SummaryStatistics
88
import simplejson as json
9+
import math
910

1011
@process(
1112
title = 'Summarize Attribute Values',
@@ -70,15 +71,16 @@ def run(features, attributeName):
7071
stats['type'] = 'string'
7172

7273
if stats['type'] == 'number':
73-
stats['min'] = ss.getMin()
74-
stats['max'] = ss.getMax()
75-
stats['range'] = stats['max'] - stats['min']
76-
stats['sum'] = ss.getSum()
77-
stats['mean'] = ss.getMean()
78-
stats['median'] = ds.getPercentile(50)
79-
stats['stdDev'] = ds.getStandardDeviation()
80-
stats['variance'] = ss.getPopulationVariance()
74+
if ss.getN():
75+
stats['min'] = ss.getMin()
76+
stats['max'] = ss.getMax()
77+
stats['range'] = stats['max'] - stats['min']
78+
stats['sum'] = ss.getSum()
79+
stats['mean'] = ss.getMean()
80+
stats['median'] = ds.getPercentile(50)
81+
stats['stdDev'] = ds.getStandardDeviation()
82+
stats['variance'] = ss.getPopulationVariance()
8183

8284
stats['uniqueValueCount'] = len(stats['uniqueValues'])
83-
84-
return json.dumps(stats)
85+
86+
return json.dumps(stats, allow_nan=False)

0 commit comments

Comments
 (0)