Skip to content

Commit

Permalink
apacheGH-41924: [Python] Fix tests when using NumPy 2.0 on Windows (a…
Browse files Browse the repository at this point in the history
…pache#42099)

### Rationale for this change

The tests are failing on windows when using numpy 2.0 RC, probably related to default integer bitwidth.

### What changes are included in this PR?

### Are these changes tested?

### Are there any user-facing changes?

* GitHub issue: apache#41319
* GitHub Issue: apache#41924

Authored-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
Signed-off-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
  • Loading branch information
jorisvandenbossche authored Jun 13, 2024
1 parent aea10c2 commit 680980e
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion python/pyarrow/tests/parquet/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def _random_integers(size, dtype):
iinfo = np.iinfo(dtype)
return np.random.randint(max(iinfo.min, platform_int_info.min),
min(iinfo.max, platform_int_info.max),
size=size).astype(dtype)
size=size, dtype=dtype)


def _range_integers(size, dtype):
Expand Down
2 changes: 1 addition & 1 deletion python/pyarrow/tests/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -3398,7 +3398,7 @@ def test_numpy_array_protocol():
result = np.asarray(arr)
np.testing.assert_array_equal(result, expected)

if Version(np.__version__) < Version("2.0"):
if Version(np.__version__) < Version("2.0.0.dev0"):
# copy keyword is not strict and not passed down to __array__
result = np.array(arr, copy=False)
np.testing.assert_array_equal(result, expected)
Expand Down
2 changes: 1 addition & 1 deletion python/pyarrow/tests/test_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ def test_integer_no_nulls(self):
info = np.iinfo(dtype)
values = np.random.randint(max(info.min, np.iinfo(np.int_).min),
min(info.max, np.iinfo(np.int_).max),
size=num_values)
size=num_values, dtype=dtype)
data[dtype] = values.astype(dtype)
fields.append(pa.field(dtype, arrow_dtype))

Expand Down
2 changes: 1 addition & 1 deletion python/pyarrow/tests/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -3281,7 +3281,7 @@ def test_numpy_array_protocol(constructor):
table = constructor([[1, 2, 3], [4.0, 5.0, 6.0]], names=["a", "b"])
expected = np.array([[1, 4], [2, 5], [3, 6]], dtype="float64")

if Version(np.__version__) < Version("2.0"):
if Version(np.__version__) < Version("2.0.0.dev0"):
# copy keyword is not strict and not passed down to __array__
result = np.array(table, copy=False)
np.testing.assert_array_equal(result, expected)
Expand Down
2 changes: 1 addition & 1 deletion python/scripts/test_leak.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def func():


def test_ARROW_8801():
x = pd.to_datetime(np.random.randint(0, 2**32, size=2**20),
x = pd.to_datetime(np.random.randint(0, 2**32, size=2**20, dtype=np.int64),
unit='ms', utc=True)
table = pa.table(pd.DataFrame({'x': x}))

Expand Down

0 comments on commit 680980e

Please sign in to comment.