@@ -81,7 +81,7 @@ def test_convert_value_raises(value, feature):
8181@pytest .mark .parametrize (
8282 'value,feature,expected_value' ,
8383 [
84- # datetime
84+ # Datetime.
8585 (
8686 datetime .datetime (1970 , 1 , 1 , tzinfo = datetime .timezone .utc ),
8787 feature_lib .Scalar (dtype = np .int64 ),
@@ -92,14 +92,14 @@ def test_convert_value_raises(value, feature):
9292 feature_lib .Scalar (dtype = np .int64 ),
9393 86400 ,
9494 ),
95- # scalar
95+ # Scalar.
9696 (42 , feature_lib .Scalar (dtype = np .int64 ), 42 ),
9797 (42 , feature_lib .Scalar (dtype = np .int32 ), 42 ),
9898 ('abc' , feature_lib .Scalar (dtype = np .object_ ), 'abc' ),
9999 (True , feature_lib .Scalar (dtype = np .bool_ ), True ),
100100 (False , feature_lib .Scalar (dtype = np .bool_ ), False ),
101101 (42.0 , feature_lib .Scalar (dtype = np .float32 ), 42.0 ),
102- # sequence
102+ # Sequence.
103103 ([42 ], feature_lib .Sequence (feature = tf .int64 ), [42 ]),
104104 (42 , feature_lib .Sequence (feature = tf .int64 ), [42 ]),
105105 (None , feature_lib .Sequence (feature = tf .int64 ), []),
@@ -111,15 +111,15 @@ def test_convert_value_raises(value, feature):
111111 ),
112112 {'someint' : [b'' , 'string' , b'' ]},
113113 ),
114- # image
114+ # Image.
115115 (
116116 lazy_imports_lib .lazy_imports .PIL_Image .new (mode = 'L' , size = (4 , 4 )),
117117 feature_lib .Image (),
118118 lazy_imports_lib .lazy_imports .PIL_Image .new (
119119 mode = 'RGB' , size = (4 , 4 )
120120 ),
121121 ),
122- # dict
122+ # Dict.
123123 (
124124 {
125125 'de' : b'Hallo Welt' ,
@@ -148,7 +148,18 @@ def test_convert_value_raises(value, feature):
148148 }),
149149 {'name' : b'Name' , 'age' : 100 },
150150 ),
151- # nan, but the feature type is not float
151+ # Video.
152+ (
153+ {'path' : 'path/to/video.avi' , 'bytes' : None },
154+ feature_lib .Video (),
155+ 'path/to/video.avi' ,
156+ ),
157+ (
158+ {'path' : None , 'bytes' : b'video_bytes' },
159+ feature_lib .Video (),
160+ b'video_bytes' ,
161+ ),
162+ # nan, but the feature type is not float.
152163 (
153164 np .nan ,
154165 feature_lib .Text (),
0 commit comments