Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[processing] fixed handling of integer values
  • Loading branch information
volaya committed Oct 5, 2016
1 parent 4184934 commit bc0cdc7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion python/plugins/processing/core/parameters.py
Expand Up @@ -30,6 +30,7 @@

import sys
import os
import math
from inspect import isclass
from copy import deepcopy
import numbers
Expand Down Expand Up @@ -834,6 +835,8 @@ def setValue(self, n):
try:
v = self._evaluate(n)
self.value = float(v)
if self.isInteger:
self.value = int(math.floor(self.value))
return True
except:
return False
Expand Down Expand Up @@ -877,7 +880,10 @@ def _evaluate(self, value):
result = exp.evaluate(_expressionContext())
if exp.hasEvalError():
raise ValueError("Error evaluating parameter expression: " + exp.evalErrorString())
return result
if self.isInteger:
return math.floor(result)
else:
return result

def evaluate(self, alg):
if isinstance(self.value, str) and bool(self.value):
Expand Down

0 comments on commit bc0cdc7

Please sign in to comment.