@@ -482,6 +482,38 @@ def test_create_with_list_of_lists(self):
482482 assert_array_equal (ps ['a' ], np .array (
483483 [Sequence ([1 , 2 , 3 ]), Sequence ([4 , 5 , 6 ])], dtype = Sequence ))
484484
485+ def test_create_with_plain_list_produces_sequence (self ):
486+ schema = {'a' : Sequence }
487+ ps = ParameterSpace ({'a' : [1 , 2 , 3 ]}, schema , shape = (2 ,))
488+ ps .evaluate ()
489+ result = ps ['a' ]
490+ assert type (result [0 ]) == Sequence
491+ assert_array_equal (result , np .array ([Sequence ([1 , 2 , 3 ]), Sequence ([1 , 2 , 3 ])], dtype = Sequence ))
492+
493+ def test_create_with_numpy_array_produces_sequence (self ):
494+ schema = {'a' : Sequence }
495+ ps = ParameterSpace ({'a' : np .array ([1 , 2 , 3 ])}, schema , shape = (2 ,))
496+ ps .evaluate ()
497+ result = ps ['a' ]
498+ assert type (result [0 ]) == Sequence
499+ assert_array_equal (result , np .array ([Sequence ([1 , 2 , 3 ]), Sequence ([1 , 2 , 3 ])], dtype = Sequence ))
500+
501+ def test_create_with_list_of_numpy_arrays_produces_sequences (self ):
502+ schema = {'a' : Sequence }
503+ ps = ParameterSpace ({'a' : [np .array ([1 , 2 ]), np .array ([3 , 4 ])]}, schema , shape = (2 ,))
504+ ps .evaluate ()
505+ result = ps ['a' ]
506+ assert type (result [0 ]) == Sequence
507+ assert type (result [1 ]) == Sequence
508+ assert_array_equal (result , np .array ([Sequence ([1 , 2 ]), Sequence ([3 , 4 ])], dtype = Sequence ))
509+
510+ def test_create_with_empty_list_produces_sequence (self ):
511+ schema = {'a' : Sequence }
512+ ps = ParameterSpace ({'a' : []}, schema , shape = (2 ,))
513+ ps .evaluate ()
514+ result = ps ['a' ]
515+ assert type (result [0 ]) == Sequence
516+
485517 def test_keys (self ):
486518 ps = ParameterSpace ({'a' : [2 , 3 , 5 , 8 , 13 ], 'b' : 7 , 'c' : lambda i : 3 * i + 2 }, shape = (5 ,))
487519 assert list (ps .keys ()) == ["a" , "b" , "c" ]
0 commit comments