Skip to content
Open
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
8 changes: 8 additions & 0 deletions python/pyarrow/tests/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -2678,6 +2678,10 @@ def test_array_from_list_of_timestamps(unit):


@pytest.mark.numpy
@pytest.mark.filterwarnings(
"ignore:The 'generic' unit for NumPy timedelta is deprecated:"
"DeprecationWarning"
)
def test_array_from_timestamp_with_generic_unit():
n = np.datetime64('NaT')
x = np.datetime64('2017-01-01 01:01:01.111111111')
Expand Down Expand Up @@ -2718,6 +2722,10 @@ def test_array_from_numpy_timedelta(dtype, type):


@pytest.mark.numpy
@pytest.mark.filterwarnings(
"ignore:The 'generic' unit for NumPy timedelta is deprecated:"
"DeprecationWarning"
)
def test_array_from_numpy_timedelta_incorrect_unit():
# generic (no unit)
td = np.timedelta64(1)
Expand Down
6 changes: 3 additions & 3 deletions python/pyarrow/tests/test_compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -2645,8 +2645,8 @@ def _check_datetime_components(timestamps, timezone=None):
year = ts.dt.year.astype("int64")
month = ts.dt.month.astype("int64")
day = ts.dt.day.astype("int64")
dayofweek = ts.dt.dayofweek.astype("int64")
dayofyear = ts.dt.dayofyear.astype("int64")
dayofweek = ts.dt.day_of_week.astype("int64")
dayofyear = ts.dt.day_of_year.astype("int64")
quarter = ts.dt.quarter.astype("int64")
hour = ts.dt.hour.astype("int64")
minute = ts.dt.minute.astype("int64")
Expand Down Expand Up @@ -2969,7 +2969,7 @@ def test_round_temporal(unit):
if sys.platform == "win32":
timestamps = timestamps[:3] + timestamps[5:]

ts = pd.Series([pd.Timestamp(x, unit="ns") for x in timestamps])
ts = pd.Series([pd.Timestamp(x) for x in timestamps])
_check_temporal_rounding(ts, values, unit)

timezones = ["Asia/Kolkata", "America/New_York", "Etc/GMT-4", "Etc/GMT+4",
Expand Down
2 changes: 1 addition & 1 deletion python/pyarrow/tests/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def multisourcefs(request):

# create one with schema partitioning by weekday and color
mockfs.create_dir('schema')
for part, chunk in df_b.groupby([df_b.date.dt.dayofweek, df_b.color]):
for part, chunk in df_b.groupby([df_b.date.dt.day_of_week, df_b.color]):
folder = f'schema/{part[0]}/{part[1]}'
path = f'{folder}/chunk.parquet'
mockfs.create_dir(folder)
Expand Down
19 changes: 10 additions & 9 deletions python/pyarrow/tests/test_dlpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,11 @@ def immutable_tensor():
@pytest.mark.parametrize('max_version', [None, (0, 8)])
def test_dlpack_legacy_capsule_immutable_tensor(max_version):
tensor = immutable_tensor()
with pytest.raises(NotImplementedError,
match="Legacy DLPack support is not implemented "
"for immutable tensors"):
tensor.__dlpack__(max_version=max_version)
with pytest.warns(DeprecationWarning, match="unversioned DLPack capsule"):
with pytest.raises(NotImplementedError,
match="Legacy DLPack support is not implemented "
"for immutable tensors"):
tensor.__dlpack__(max_version=max_version)


@check_bytes_allocated
Expand Down Expand Up @@ -307,7 +308,7 @@ def test_dlpack_versioned_capsule(obj, max_version, copy):
@check_bytes_allocated
@pytest.mark.parametrize('obj', dlpack_objects())
def test_dlpack_versioned_roundtrip(obj):
expected = np.from_dlpack(DLPackForwarder(obj, max_version=None))
expected = np.from_dlpack(DLPackForwarder(obj, max_version=(1, 0)))
for copy in [None, False, True]:
result = np.from_dlpack(
DLPackForwarder(obj, max_version=(1, 0), copy=copy))
Expand Down Expand Up @@ -335,24 +336,24 @@ def test_dlpack_not_supported():
arr = pa.array([1, None, 3])
with pytest.raises(TypeError, match="Can only use DLPack "
"on arrays with no nulls."):
np.from_dlpack(arr)
np.from_dlpack(DLPackForwarder(arr, max_version=(1, 0)))

arr = pa.array(
[[0, 1], [3, 4]],
type=pa.list_(pa.int32())
)
with pytest.raises(TypeError, match="DataType is not compatible with DLPack spec"):
np.from_dlpack(arr)
np.from_dlpack(DLPackForwarder(arr, max_version=(1, 0)))

arr = pa.array([])
with pytest.raises(TypeError, match="DataType is not compatible with DLPack spec"):
np.from_dlpack(arr)
np.from_dlpack(DLPackForwarder(arr, max_version=(1, 0)))

# DLPack doesn't support bit-packed boolean values
arr = pa.array([True, False, True])
with pytest.raises(TypeError, match="Bit-packed boolean data type "
"not supported by DLPack."):
np.from_dlpack(arr)
np.from_dlpack(DLPackForwarder(arr, max_version=(1, 0)))


def test_dlpack_cuda_not_supported():
Expand Down
3 changes: 2 additions & 1 deletion python/pyarrow/tests/test_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ def _check_pandas_roundtrip(df, expected=None, use_threads=False,
warnings.filterwarnings(
"ignore", "elementwise comparison failed", DeprecationWarning)
tm.assert_frame_equal(result, expected, check_dtype=check_dtype,
check_freq=False,
check_index_type=('equiv' if preserve_index
else False))

Expand Down Expand Up @@ -5006,7 +5007,7 @@ def test_does_not_mutate_timedelta_dtype():

assert np.dtype(np.timedelta64) == expected

df = pd.DataFrame({"a": [np.timedelta64()]})
df = pd.DataFrame({"a": [np.timedelta64(0, "ns")]})
t = pa.Table.from_pandas(df)
t.to_pandas()

Expand Down