8686 (((1.0 , 2.0 ), (3.0 , 4.0 )), "Collection.Collection.float" ),
8787 ((set ([1.0 , 2.0 ]), set ([3.0 , 4.0 ])), "Collection.Collection.float" ),
8888 ((frozenset ([1.0 , 2.0 ]), frozenset ([3.0 , 4.0 ])), "Collection.Collection.float" ),
89+ (set ([(1.0 , 2.0 ), (3.0 , 4.0 )]), "Collection.Collection.float" ),
90+ (set ([frozenset ([1.0 , 2.0 ]), frozenset ([3.0 , 4.0 ])]), "Collection.Collection.float" ),
91+ (frozenset ([(1.0 , 2.0 ), (3.0 , 4.0 )]), "Collection.Collection.float" ),
92+ (frozenset ([frozenset ([1.0 , 2.0 ]), frozenset ([3.0 , 4.0 ])]), "Collection.Collection.float" ),
8993 ],
9094)
9195def test___various_python_objects___get_best_matching_type___returns_correct_type_string (
@@ -224,8 +228,6 @@ def test___python_analog_waveform___to_any___valid_double_analog_waveform() -> N
224228 (((1.0 , 2.0 ), (3.0 , 4.0 ))),
225229 ((set ([1.0 , 2.0 ]), set ([3.0 , 4.0 ]))),
226230 ((frozenset ([1.0 , 2.0 ]), frozenset ([3.0 , 4.0 ]))),
227- # sets and frozensets of collections don't preserve order,
228- # so they need to be tested separately.
229231 ],
230232)
231233def test___python_2dcollection_of_float___to_any___valid_double2darray (
@@ -244,6 +246,32 @@ def test___python_2dcollection_of_float___to_any___valid_double2darray(
244246 assert unpack_dest .data == expected_data
245247
246248
249+ @pytest .mark .parametrize (
250+ "python_value" ,
251+ [
252+ (set ([(1.0 , 2.0 ), (3.0 , 4.0 )])),
253+ (set ([frozenset ([1.0 , 2.0 ]), frozenset ([3.0 , 4.0 ])])),
254+ (frozenset ([(1.0 , 2.0 ), (3.0 , 4.0 )])),
255+ (frozenset ([frozenset ([1.0 , 2.0 ]), frozenset ([3.0 , 4.0 ])])),
256+ ],
257+ )
258+ def test___python_set_of_collection_of_float___to_any___valid_double2darray (
259+ python_value : Collection [Collection [float ]],
260+ ) -> None :
261+ expected_data = [1.0 , 2.0 , 3.0 , 4.0 ]
262+ expected_rows = 2
263+ expected_columns = 2
264+ result = nipanel ._convert .to_any (python_value )
265+ unpack_dest = Double2DArray ()
266+ _assert_any_and_unpack (result , unpack_dest )
267+
268+ assert isinstance (unpack_dest , Double2DArray )
269+ assert unpack_dest .rows == expected_rows
270+ assert unpack_dest .columns == expected_columns
271+ # Sets and frozensets don't maintain order, so sort before comparing.
272+ assert sorted (unpack_dest .data ) == sorted (expected_data )
273+
274+
247275# ========================================================
248276# Protobuf Types: Protobuf to Python
249277# ========================================================
0 commit comments