Skip to content

Commit bc0cdc7

Browse files
committedOct 5, 2016
[processing] fixed handling of integer values
1 parent 4184934 commit bc0cdc7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed
 

‎python/plugins/processing/core/parameters.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
import sys
3232
import os
33+
import math
3334
from inspect import isclass
3435
from copy import deepcopy
3536
import numbers
@@ -834,6 +835,8 @@ def setValue(self, n):
834835
try:
835836
v = self._evaluate(n)
836837
self.value = float(v)
838+
if self.isInteger:
839+
self.value = int(math.floor(self.value))
837840
return True
838841
except:
839842
return False
@@ -877,7 +880,10 @@ def _evaluate(self, value):
877880
result = exp.evaluate(_expressionContext())
878881
if exp.hasEvalError():
879882
raise ValueError("Error evaluating parameter expression: " + exp.evalErrorString())
880-
return result
883+
if self.isInteger:
884+
return math.floor(result)
885+
else:
886+
return result
881887

882888
def evaluate(self, alg):
883889
if isinstance(self.value, str) and bool(self.value):

0 commit comments

Comments
 (0)
Please sign in to comment.