| |
@@ -1,153 +0,0 @@
|
| |
- From 6d6e5fc28f5cb4543cea9f7280831e4118b91e41 Mon Sep 17 00:00:00 2001
|
| |
- From: "Benjamin A. Beasley" <code@musicinmybrain.net>
|
| |
- Date: Sun, 8 Jan 2023 15:53:55 -0500
|
| |
- Subject: [PATCH 1/2] In Python tests, use host-endian-independent dtypes
|
| |
-
|
| |
- ---
|
| |
- tests/py_test.py | 30 +++++++++++++++---------------
|
| |
- 1 file changed, 15 insertions(+), 15 deletions(-)
|
| |
-
|
| |
- diff --git a/tests/py_test.py b/tests/py_test.py
|
| |
- index 204a96dd4be..70cf07b989b 100644
|
| |
- --- a/tests/py_test.py
|
| |
- +++ b/tests/py_test.py
|
| |
- @@ -701,18 +701,18 @@ def asserter(stmt):
|
| |
- import numpy as np
|
| |
-
|
| |
- asserter(monster.InventoryAsNumpy().sum() == 10)
|
| |
- - asserter(monster.InventoryAsNumpy().dtype == np.dtype('uint8'))
|
| |
- + asserter(monster.InventoryAsNumpy().dtype == np.dtype('<u1'))
|
| |
-
|
| |
- VectorOfLongs = monster.VectorOfLongsAsNumpy()
|
| |
- - asserter(VectorOfLongs.dtype == np.dtype('int64'))
|
| |
- + asserter(VectorOfLongs.dtype == np.dtype('<i8'))
|
| |
- for i in range(5):
|
| |
- asserter(VectorOfLongs[i] == 10**(i * 2))
|
| |
-
|
| |
- VectorOfDoubles = monster.VectorOfDoublesAsNumpy()
|
| |
- - asserter(VectorOfDoubles.dtype == np.dtype('float64'))
|
| |
- - asserter(VectorOfDoubles[0] == np.finfo('float64').min)
|
| |
- + asserter(VectorOfDoubles.dtype == np.dtype('<f8'))
|
| |
- + asserter(VectorOfDoubles[0] == np.finfo('<f8').min)
|
| |
- asserter(VectorOfDoubles[1] == 0.0)
|
| |
- - asserter(VectorOfDoubles[2] == np.finfo('float64').max)
|
| |
- + asserter(VectorOfDoubles[2] == np.finfo('<f8').max)
|
| |
-
|
| |
- except ImportError:
|
| |
- # If numpy does not exist, trying to get vector as numpy
|
| |
- @@ -857,33 +857,33 @@ def check(table, desc, want, got):
|
| |
- check(table, 'bool', self.boolVal,
|
| |
- table.GetSlot(f, False, N.BoolFlags))
|
| |
- elif choice == 1:
|
| |
- - check(table, 'int8', self.int8Val, table.GetSlot(f, 0, N.Int8Flags))
|
| |
- + check(table, '<i1', self.int8Val, table.GetSlot(f, 0, N.Int8Flags))
|
| |
- elif choice == 2:
|
| |
- - check(table, 'uint8', self.uint8Val,
|
| |
- + check(table, '<u1', self.uint8Val,
|
| |
- table.GetSlot(f, 0, N.Uint8Flags))
|
| |
- elif choice == 3:
|
| |
- - check(table, 'int16', self.int16Val,
|
| |
- + check(table, '<i2', self.int16Val,
|
| |
- table.GetSlot(f, 0, N.Int16Flags))
|
| |
- elif choice == 4:
|
| |
- - check(table, 'uint16', self.uint16Val,
|
| |
- + check(table, '<u2', self.uint16Val,
|
| |
- table.GetSlot(f, 0, N.Uint16Flags))
|
| |
- elif choice == 5:
|
| |
- - check(table, 'int32', self.int32Val,
|
| |
- + check(table, '<i4', self.int32Val,
|
| |
- table.GetSlot(f, 0, N.Int32Flags))
|
| |
- elif choice == 6:
|
| |
- - check(table, 'uint32', self.uint32Val,
|
| |
- + check(table, '<u4', self.uint32Val,
|
| |
- table.GetSlot(f, 0, N.Uint32Flags))
|
| |
- elif choice == 7:
|
| |
- - check(table, 'int64', self.int64Val,
|
| |
- + check(table, '<i8', self.int64Val,
|
| |
- table.GetSlot(f, 0, N.Int64Flags))
|
| |
- elif choice == 8:
|
| |
- - check(table, 'uint64', self.uint64Val,
|
| |
- + check(table, '<u8', self.uint64Val,
|
| |
- table.GetSlot(f, 0, N.Uint64Flags))
|
| |
- elif choice == 9:
|
| |
- - check(table, 'float32', self.float32Val,
|
| |
- + check(table, '<f4', self.float32Val,
|
| |
- table.GetSlot(f, 0, N.Float32Flags))
|
| |
- elif choice == 10:
|
| |
- - check(table, 'float64', self.float64Val,
|
| |
- + check(table, '<f8', self.float64Val,
|
| |
- table.GetSlot(f, 0, N.Float64Flags))
|
| |
- else:
|
| |
- raise RuntimeError('unreachable')
|
| |
-
|
| |
- From 85285ac9efce74320d367c7d8c7874b4d55cfb10 Mon Sep 17 00:00:00 2001
|
| |
- From: "Benjamin A. Beasley" <code@musicinmybrain.net>
|
| |
- Date: Sun, 8 Jan 2023 19:56:42 -0500
|
| |
- Subject: [PATCH 2/2] Fix host endianness dependence in Python flexbuffers
|
| |
-
|
| |
- ---
|
| |
- python/flatbuffers/flexbuffers.py | 10 +++++-----
|
| |
- tests/py_flexbuffers_test.py | 6 +++---
|
| |
- 2 files changed, 8 insertions(+), 8 deletions(-)
|
| |
-
|
| |
- diff --git a/python/flatbuffers/flexbuffers.py b/python/flatbuffers/flexbuffers.py
|
| |
- index aaa02fdaf3f..34d42a6986c 100644
|
| |
- --- a/python/flatbuffers/flexbuffers.py
|
| |
- +++ b/python/flatbuffers/flexbuffers.py
|
| |
- @@ -75,7 +75,7 @@ def I(value):
|
| |
- @staticmethod
|
| |
- def F(value):
|
| |
- """Returns the `BitWidth` to encode floating point value."""
|
| |
- - if struct.unpack('f', struct.pack('f', value))[0] == value:
|
| |
- + if struct.unpack('<f', struct.pack('<f', value))[0] == value:
|
| |
- return BitWidth.W32
|
| |
- return BitWidth.W64
|
| |
-
|
| |
- @@ -95,20 +95,20 @@ def B(byte_width):
|
| |
-
|
| |
-
|
| |
- def _Unpack(fmt, buf):
|
| |
- - return struct.unpack(fmt[len(buf)], buf)[0]
|
| |
- + return struct.unpack('<%s' % fmt[len(buf)], buf)[0]
|
| |
-
|
| |
-
|
| |
- def _UnpackVector(fmt, buf, length):
|
| |
- byte_width = len(buf) // length
|
| |
- - return struct.unpack('%d%s' % (length, fmt[byte_width]), buf)
|
| |
- + return struct.unpack('<%d%s' % (length, fmt[byte_width]), buf)
|
| |
-
|
| |
-
|
| |
- def _Pack(fmt, value, byte_width):
|
| |
- - return struct.pack(fmt[byte_width], value)
|
| |
- + return struct.pack('<%s' % fmt[byte_width], value)
|
| |
-
|
| |
-
|
| |
- def _PackVector(fmt, values, byte_width):
|
| |
- - return struct.pack('%d%s' % (len(values), fmt[byte_width]), *values)
|
| |
- + return struct.pack('<%d%s' % (len(values), fmt[byte_width]), *values)
|
| |
-
|
| |
-
|
| |
- def _Mutate(fmt, buf, value, byte_width, value_bit_width):
|
| |
- diff --git a/tests/py_flexbuffers_test.py b/tests/py_flexbuffers_test.py
|
| |
- index 6696b3e23e4..fcd17faaa37 100644
|
| |
- --- a/tests/py_flexbuffers_test.py
|
| |
- +++ b/tests/py_flexbuffers_test.py
|
| |
- @@ -74,15 +74,15 @@ def int_sizes(value):
|
| |
-
|
| |
-
|
| |
- def int_bytes(value, byte_width):
|
| |
- - return struct.pack({1: 'b', 2: 'h', 4: 'i', 8: 'q'}[byte_width], value)
|
| |
- + return struct.pack('<%s' % {1: 'b', 2: 'h', 4: 'i', 8: 'q'}[byte_width], value)
|
| |
-
|
| |
-
|
| |
- def uint_bytes(value, byte_width):
|
| |
- - return struct.pack({1: 'B', 2: 'H', 4: 'I', 8: 'Q'}[byte_width], value)
|
| |
- + return struct.pack('<%s' % {1: 'B', 2: 'H', 4: 'I', 8: 'Q'}[byte_width], value)
|
| |
-
|
| |
-
|
| |
- def float_bytes(value, byte_width):
|
| |
- - return struct.pack({4: 'f', 8: 'd'}[byte_width], value)
|
| |
- + return struct.pack('<%s' % {4: 'f', 8: 'd'}[byte_width], value)
|
| |
-
|
| |
-
|
| |
- def min_value(type_, byte_width):
|
| |
https://github.com/google/flatbuffers/compare/v23.1.4...v23.1.21
https://github.com/google/flatbuffers/releases/tag/v23.1.21
https://github.com/google/flatbuffers/releases/tag/v23.1.20
Announced to the
devel
list 2022-01-23. Merge and build no earlier than 2022-01-30.