@@ -178,6 +178,43 @@ def test_create_dataset_with_custom_generator(tmp_path, fixed_length_packet_defi
178178 assert list (dataset ["INT32_FIELD" ].values ) == [12345 , 67890 , - 99999 ]
179179
180180
181+ def test_create_dataset_preserves_binary_parameter_width (tmp_path ):
182+ """Test that binary parameters keep their full byte width in the resulting dataset."""
183+ packet_definition = definitions .XtcePacketDefinition (
184+ container_set = [
185+ containers .SequenceContainer (
186+ "BINARY_CONTAINER" ,
187+ entry_list = [
188+ parameters .Parameter (
189+ "BIN_FIELD" ,
190+ parameter_type = parameter_types .BinaryParameterType (
191+ "BIN_TYPE" , encoding = encodings .BinaryDataEncoding (fixed_size_in_bits = 64 )
192+ ),
193+ )
194+ ],
195+ )
196+ ]
197+ )
198+ packet_data = b"ABCDEFGH"
199+ test_file = tmp_path / "binary_packets.bin"
200+ test_file .write_bytes (packet_data )
201+
202+ datasets = xarr .create_dataset (
203+ test_file ,
204+ packet_definition ,
205+ packet_bytes_generator = fixed_length_generator ,
206+ generator_kwargs = {"packet_length_bytes" : 8 },
207+ parse_bytes_kwargs = {"root_container_name" : "BINARY_CONTAINER" },
208+ )
209+
210+ dataset = list (datasets .values ())[0 ]
211+
212+ assert dataset ["BIN_FIELD" ].values .dtype .kind == "S" # Should be a bytes/string type
213+ assert dataset ["BIN_FIELD" ].values .dtype .itemsize == 8
214+ assert dataset ["BIN_FIELD" ].values .dtype == "|S8"
215+ assert dataset ["BIN_FIELD" ].values .tolist () == [packet_data ]
216+
217+
181218def test_create_dataset_with_packet_filter (tmp_path , fixed_length_packet_definition , fixed_length_test_packets ):
182219 """Test filtering packets with packet_filter parameter using raw byte inspection"""
183220 _ , _ , _ , binary_data = fixed_length_test_packets
0 commit comments