Skip to content

Commit c50b06a

Browse files
author
Ignacio Quintero
committed
Fix broken unit tests
My previous commit broke a couple of unit tests. This fixes them.
1 parent 6834806 commit c50b06a

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/sagemaker/amazon/hyperparameter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def __get__(self, obj, objtype):
5252

5353
def __set__(self, obj, value):
5454
"""Validate the supplied value and set this hyperparameter to value"""
55-
value = self.data_type(value)
55+
value = None if value is None else self.data_type(value)
5656
self.validate(value)
5757
if '_hyperparameters' not in dir(obj):
5858
obj._hyperparameters = dict()

tests/unit/test_hyperparameter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
class Test(object):
1818

19-
blank = Hyperparameter(name="some-name")
19+
blank = Hyperparameter(name="some-name", data_type=int)
2020
elizabeth = Hyperparameter(name='elizabeth')
2121
validated = Hyperparameter(name="validated", validate=lambda value: value > 55, data_type=int)
2222

@@ -70,5 +70,5 @@ def test_from_string():
7070
x.validated = value
7171
from_api = str(value)
7272

73-
x.validated = Test.__dict__["validated"].data_type(from_api)
73+
x.validated = from_api
7474
assert x.validated == value

0 commit comments

Comments
 (0)