Commit 63328576 authored by David Trudgian's avatar David Trudgian
Browse files

Force int/float parse, don't rely on implicit parsing to type

parent 5ed5e675
......@@ -167,7 +167,7 @@ class ParamFile(object):
param['range'] = ir.to_list()
if param['type'] == 'real_range':
rr = IntRange(param)
rr = RealRange(param)
param['range'] = rr.to_list()
if param['type'] == 'choice':
......@@ -288,11 +288,11 @@ class IntRange(object):
def to_list(self):
min_val = self.param['min']
max_val = self.param['max']
min_val = int(self.param['min'])
max_val = int(self.param['max'])
step = self.param.get('step', 1)
scale = self.param.get('scale', 1)
step = int(self.param.get('step', 1))
scale = int(self.param.get('scale', 1))
# Special case - if only scale specified then assume no step
if 'scale' in self.param and 'step' not in self.param:
......@@ -320,7 +320,30 @@ class RealRange(IntRange):
"""
pass
def to_list(self):
min_val = float(self.param['min'])
max_val = float(self.param['max'])
step = float(self.param.get('step', 1.0))
scale = float(self.param.get('scale', 1.0))
# Special case - if only scale specified then assume no step
if 'scale' in self.param and 'step' not in self.param:
step = 0.0
current = min_val
vals = []
if self.param.get('optional', False):
vals.append(None)
while current <= max_val:
vals.append(current)
current = (current * scale) + step
return vals
class ChoiceRange(object):
......
......@@ -77,7 +77,7 @@ parameters:
flag: '-b'
optional: true
min: 0.1
max: 100
max: 1e2
scale: 10
description: Regularization beta parameter
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment