Skip to content

CoW: Fix test that is failing with new arrow version #54112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pandas/compat/pyarrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
pa_version_under9p0 = _palv < Version("9.0.0")
pa_version_under10p0 = _palv < Version("10.0.0")
pa_version_under11p0 = _palv < Version("11.0.0")
pa_version_under12p0 = _palv < Version("12.0.0")
pa_version_under13p0 = _palv < Version("13.0.0")
except ImportError:
pa_version_under7p0 = True
pa_version_under8p0 = True
pa_version_under9p0 = True
pa_version_under10p0 = True
pa_version_under11p0 = True
pa_version_under12p0 = True
pa_version_under13p0 = True
14 changes: 9 additions & 5 deletions pandas/tests/copy_view/test_astype.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import pytest

from pandas.compat import pa_version_under7p0
from pandas.compat.pyarrow import pa_version_under12p0
import pandas.util._test_decorators as td

import pandas as pd
Expand Down Expand Up @@ -200,11 +201,14 @@ def test_astype_arrow_timestamp(using_copy_on_write):
result = df.astype("timestamp[ns][pyarrow]")
if using_copy_on_write:
assert not result._mgr._has_no_reference(0)
# TODO(CoW): arrow is not setting copy=False in the Series constructor
# under the hood
assert not np.shares_memory(
get_array(df, "a"), get_array(result, "a")._pa_array
)
if pa_version_under12p0:
assert not np.shares_memory(
get_array(df, "a"), get_array(result, "a")._pa_array
)
else:
assert np.shares_memory(
get_array(df, "a"), get_array(result, "a")._pa_array
)


def test_convert_dtypes_infer_objects(using_copy_on_write):
Expand Down