Skip to content

Commit 5f4835e

Browse files
committed
allow absolute accuracy criterion to be integer besides str and float
1 parent 12f2ef2 commit 5f4835e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lpot/conf/config.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,10 @@ def list_to_tuple(data):
123123
def percent_to_float(data):
124124
if isinstance(data, str) and re.match(r'-?\d+(\.\d+)?%', data):
125125
data = float(data.strip('%')) / 100
126+
if isinstance(data, int):
127+
data = float(data)
126128
else:
127-
assert isinstance(data, float), 'This field should be float or percent string'
129+
assert isinstance(data, float), 'This field should be float, int or percent string'
128130
return data
129131

130132
policy_schema = Schema({
@@ -459,7 +461,7 @@ def percent_to_float(data):
459461
Hook('accuracy_criterion', handler=_valid_accuracy_field): object,
460462
Optional('accuracy_criterion', default={'relative': 0.01}): {
461463
Optional('relative'): And(Or(str, float), Use(percent_to_float)),
462-
Optional('absolute'): And(Or(str, float), Use(percent_to_float)),
464+
Optional('absolute'): And(Or(str, int, float), Use(percent_to_float)),
463465
Optional('higher_is_better', default=True): bool,
464466
},
465467
Optional('objective', default='performance'): And(str, lambda s: s in OBJECTIVES),

0 commit comments

Comments
 (0)