summaryrefslogtreecommitdiff
path: root/dev-python/flatbuffers/files/flatbuffers-24.3.25-numpy-2.patch
blob: cc584640476439e4b6a3f1509a6b90e754c73fe1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
From d053fbd391610e72fff1f8ee02c1222305f15de9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20Van=C4=9Bk?= <arkamar@gentoo.org>
Date: Mon, 1 Jul 2024 10:29:39 +0000
Subject: [PATCH] Support for Numpy 2.0 in tests

The newbyteorder has been removed in Numpy 2.0 [1]. Its usages are
replaced with respect to migration guide.

[1] https://numpy.org/devdocs/numpy_2_0_migration_guide.html#ndarray-and-scalar-methods

Fixes: #8332

Upstream-PR: https://github.com/google/flatbuffers/pull/8346

diff --git a/tests/py_test.py b/tests/py_test.py
index 7d6c0a37966..fc13a490f71 100644
--- a/tests/py_test.py
+++ b/tests/py_test.py
@@ -1095,7 +1095,7 @@ def test_create_numpy_vector_int8(self):
 
       # Reverse endian:
       b = flatbuffers.Builder(0)
-      x_other_endian = x.byteswap().newbyteorder()
+      x_other_endian = x.byteswap().view(x.dtype.newbyteorder())
       b.CreateNumpyVector(x_other_endian)
       self.assertBuilderEquals(
           b,
@@ -1144,7 +1144,7 @@ def test_create_numpy_vector_uint16(self):
 
       # Reverse endian:
       b = flatbuffers.Builder(0)
-      x_other_endian = x.byteswap().newbyteorder()
+      x_other_endian = x.byteswap().view(x.dtype.newbyteorder())
       b.CreateNumpyVector(x_other_endian)
       self.assertBuilderEquals(
           b,
@@ -1213,7 +1213,7 @@ def test_create_numpy_vector_int64(self):
 
       # Reverse endian:
       b = flatbuffers.Builder(0)
-      x_other_endian = x.byteswap().newbyteorder()
+      x_other_endian = x.byteswap().view(x.dtype.newbyteorder())
       b.CreateNumpyVector(x_other_endian)
       self.assertBuilderEquals(
           b,
@@ -1287,7 +1287,7 @@ def test_create_numpy_vector_float32(self):
 
       # Reverse endian:
       b = flatbuffers.Builder(0)
-      x_other_endian = x.byteswap().newbyteorder()
+      x_other_endian = x.byteswap().view(x.dtype.newbyteorder())
       b.CreateNumpyVector(x_other_endian)
       self.assertBuilderEquals(
           b,
@@ -1361,7 +1361,7 @@ def test_create_numpy_vector_float64(self):
 
       # Reverse endian:
       b = flatbuffers.Builder(0)
-      x_other_endian = x.byteswap().newbyteorder()
+      x_other_endian = x.byteswap().view(x.dtype.newbyteorder())
       b.CreateNumpyVector(x_other_endian)
       self.assertBuilderEquals(
           b,
@@ -1427,7 +1427,7 @@ def test_create_numpy_vector_bool(self):
 
       # Reverse endian:
       b = flatbuffers.Builder(0)
-      x_other_endian = x.byteswap().newbyteorder()
+      x_other_endian = x.byteswap().view(x.dtype.newbyteorder())
       b.CreateNumpyVector(x_other_endian)
       self.assertBuilderEquals(
           b,