MCPcopy Create free account
hub / github.com/apache/fory / test_bfloat16_array_round_trip

Function test_bfloat16_array_round_trip

python/pyfory/tests/test_serializer.py:315–323  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

313
314
315def test_bfloat16_array_round_trip():
316 fory = Fory(xlang=True, compatible=False, ref=False)
317 values = pyfory.BFloat16Array.from_values([0.0, 1.0, -2.0])
318 typeinfo = fory.type_resolver.get_type_info(pyfory.BFloat16Array)
319 assert isinstance(typeinfo.serializer, fory_array_serializer_type(TypeId.BFLOAT16_ARRAY))
320 assert typeinfo.type_id == TypeId.BFLOAT16_ARRAY
321 decoded = ser_de(fory, values)
322 assert isinstance(decoded, pyfory.BFloat16Array)
323 assert list(decoded.to_buffer()) == [0x0000, 0x3F80, 0xC000]
324
325
326def test_bfloat16_array_from_values():

Callers

nothing calls this directly

Calls 5

ForyClass · 0.90
ser_deFunction · 0.70
listFunction · 0.50
get_type_infoMethod · 0.45

Tested by

no test coverage detected