Skip to content

Commit 1783636

Browse files
jbrockmendelpull[bot]
authored andcommitted
DEPR: remove DTA.__init__, TDA.__init__ (#58004)
* DEPR: remove DTA.__init__, TDA.__init__ * update docstring * Bump fastparquet to 2023.10.0
1 parent 5a96329 commit 1783636

21 files changed

+15
-286
lines changed

Diff for: ci/deps/actions-310.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ dependencies:
2626
- beautifulsoup4>=4.11.2
2727
- blosc>=1.21.3
2828
- bottleneck>=1.3.6
29-
- fastparquet>=2023.04.0
29+
- fastparquet>=2023.10.0
3030
- fsspec>=2022.11.0
3131
- html5lib>=1.1
3232
- hypothesis>=6.46.1

Diff for: ci/deps/actions-311-downstream_compat.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ dependencies:
2828
- beautifulsoup4>=4.11.2
2929
- blosc>=1.21.3
3030
- bottleneck>=1.3.6
31-
- fastparquet>=2023.04.0
31+
- fastparquet>=2023.10.0
3232
- fsspec>=2022.11.0
3333
- html5lib>=1.1
3434
- hypothesis>=6.46.1

Diff for: ci/deps/actions-311.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ dependencies:
2626
- beautifulsoup4>=4.11.2
2727
- blosc>=1.21.3
2828
- bottleneck>=1.3.6
29-
- fastparquet>=2023.04.0
29+
- fastparquet>=2023.10.0
3030
- fsspec>=2022.11.0
3131
- html5lib>=1.1
3232
- hypothesis>=6.46.1

Diff for: ci/deps/actions-312.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ dependencies:
2626
- beautifulsoup4>=4.11.2
2727
- blosc>=1.21.3
2828
- bottleneck>=1.3.6
29-
- fastparquet>=2023.04.0
29+
- fastparquet>=2023.10.0
3030
- fsspec>=2022.11.0
3131
- html5lib>=1.1
3232
- hypothesis>=6.46.1

Diff for: ci/deps/actions-39-minimum_versions.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ dependencies:
2929
- beautifulsoup4=4.11.2
3030
- blosc=1.21.3
3131
- bottleneck=1.3.6
32-
- fastparquet=2023.04.0
32+
- fastparquet=2023.10.0
3333
- fsspec=2022.11.0
3434
- html5lib=1.1
3535
- hypothesis=6.46.1

Diff for: ci/deps/actions-39.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ dependencies:
2626
- beautifulsoup4>=4.11.2
2727
- blosc>=1.21.3
2828
- bottleneck>=1.3.6
29-
- fastparquet>=2023.04.0
29+
- fastparquet>=2023.10.0
3030
- fsspec>=2022.11.0
3131
- html5lib>=1.1
3232
- hypothesis>=6.46.1

Diff for: ci/deps/circle-310-arm64.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ dependencies:
2727
- beautifulsoup4>=4.11.2
2828
- blosc>=1.21.3
2929
- bottleneck>=1.3.6
30-
- fastparquet>=2023.04.0
30+
- fastparquet>=2023.10.0
3131
- fsspec>=2022.11.0
3232
- html5lib>=1.1
3333
- hypothesis>=6.46.1

Diff for: doc/source/getting_started/install.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ Dependency Minimum Version pip extra Notes
361361
PyTables 3.8.0 hdf5 HDF5-based reading / writing
362362
blosc 1.21.3 hdf5 Compression for HDF5; only available on ``conda``
363363
zlib hdf5 Compression for HDF5
364-
fastparquet 2023.04.0 - Parquet reading / writing (pyarrow is default)
364+
fastparquet 2023.10.0 - Parquet reading / writing (pyarrow is default)
365365
pyarrow 10.0.1 parquet, feather Parquet, ORC, and feather reading / writing
366366
pyreadstat 1.2.0 spss SPSS files (.sav) reading
367367
odfpy 1.4.1 excel Open document format (.odf, .ods, .odt) reading / writing

Diff for: doc/source/whatsnew/v3.0.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ Optional libraries below the lowest tested version may still work, but are not c
134134
+------------------------+---------------------+
135135
| Package | New Minimum Version |
136136
+========================+=====================+
137-
| fastparquet | 2023.04.0 |
137+
| fastparquet | 2023.10.0 |
138138
+------------------------+---------------------+
139139
| adbc-driver-postgresql | 0.10.0 |
140140
+------------------------+---------------------+

Diff for: environment.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ dependencies:
3030
- beautifulsoup4>=4.11.2
3131
- blosc
3232
- bottleneck>=1.3.6
33-
- fastparquet>=2023.04.0
33+
- fastparquet>=2023.10.0
3434
- fsspec>=2022.11.0
3535
- html5lib>=1.1
3636
- hypothesis>=6.46.1

Diff for: pandas/compat/_optional.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"bs4": "4.11.2",
2626
"blosc": "1.21.3",
2727
"bottleneck": "1.3.6",
28-
"fastparquet": "2023.04.0",
28+
"fastparquet": "2023.10.0",
2929
"fsspec": "2022.11.0",
3030
"html5lib": "1.1",
3131
"hypothesis": "6.46.1",

Diff for: pandas/core/arrays/datetimelike.py

-95
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
algos,
2727
lib,
2828
)
29-
from pandas._libs.arrays import NDArrayBacked
3029
from pandas._libs.tslibs import (
3130
BaseOffset,
3231
IncompatibleFrequency,
@@ -1936,100 +1935,6 @@ class TimelikeOps(DatetimeLikeArrayMixin):
19361935
Common ops for TimedeltaIndex/DatetimeIndex, but not PeriodIndex.
19371936
"""
19381937

1939-
_default_dtype: np.dtype
1940-
1941-
def __init__(
1942-
self, values, dtype=None, freq=lib.no_default, copy: bool = False
1943-
) -> None:
1944-
warnings.warn(
1945-
# GH#55623
1946-
f"{type(self).__name__}.__init__ is deprecated and will be "
1947-
"removed in a future version. Use pd.array instead.",
1948-
FutureWarning,
1949-
stacklevel=find_stack_level(),
1950-
)
1951-
if dtype is not None:
1952-
dtype = pandas_dtype(dtype)
1953-
1954-
values = extract_array(values, extract_numpy=True)
1955-
if isinstance(values, IntegerArray):
1956-
values = values.to_numpy("int64", na_value=iNaT)
1957-
1958-
inferred_freq = getattr(values, "_freq", None)
1959-
explicit_none = freq is None
1960-
freq = freq if freq is not lib.no_default else None
1961-
1962-
if isinstance(values, type(self)):
1963-
if explicit_none:
1964-
# don't inherit from values
1965-
pass
1966-
elif freq is None:
1967-
freq = values.freq
1968-
elif freq and values.freq:
1969-
freq = to_offset(freq)
1970-
freq = _validate_inferred_freq(freq, values.freq)
1971-
1972-
if dtype is not None and dtype != values.dtype:
1973-
# TODO: we only have tests for this for DTA, not TDA (2022-07-01)
1974-
raise TypeError(
1975-
f"dtype={dtype} does not match data dtype {values.dtype}"
1976-
)
1977-
1978-
dtype = values.dtype
1979-
values = values._ndarray
1980-
1981-
elif dtype is None:
1982-
if isinstance(values, np.ndarray) and values.dtype.kind in "Mm":
1983-
dtype = values.dtype
1984-
else:
1985-
dtype = self._default_dtype
1986-
if isinstance(values, np.ndarray) and values.dtype == "i8":
1987-
values = values.view(dtype)
1988-
1989-
if not isinstance(values, np.ndarray):
1990-
raise ValueError(
1991-
f"Unexpected type '{type(values).__name__}'. 'values' must be a "
1992-
f"{type(self).__name__}, ndarray, or Series or Index "
1993-
"containing one of those."
1994-
)
1995-
if values.ndim not in [1, 2]:
1996-
raise ValueError("Only 1-dimensional input arrays are supported.")
1997-
1998-
if values.dtype == "i8":
1999-
# for compat with datetime/timedelta/period shared methods,
2000-
# we can sometimes get here with int64 values. These represent
2001-
# nanosecond UTC (or tz-naive) unix timestamps
2002-
if dtype is None:
2003-
dtype = self._default_dtype
2004-
values = values.view(self._default_dtype)
2005-
elif lib.is_np_dtype(dtype, "mM"):
2006-
values = values.view(dtype)
2007-
elif isinstance(dtype, DatetimeTZDtype):
2008-
kind = self._default_dtype.kind
2009-
new_dtype = f"{kind}8[{dtype.unit}]"
2010-
values = values.view(new_dtype)
2011-
2012-
dtype = self._validate_dtype(values, dtype)
2013-
2014-
if freq == "infer":
2015-
raise ValueError(
2016-
f"Frequency inference not allowed in {type(self).__name__}.__init__. "
2017-
"Use 'pd.array()' instead."
2018-
)
2019-
2020-
if copy:
2021-
values = values.copy()
2022-
if freq:
2023-
freq = to_offset(freq)
2024-
if values.dtype.kind == "m" and not isinstance(freq, Tick):
2025-
raise TypeError("TimedeltaArray/Index freq must be a Tick")
2026-
2027-
NDArrayBacked.__init__(self, values=values, dtype=dtype)
2028-
self._freq = freq
2029-
2030-
if inferred_freq is None and freq is not None:
2031-
type(self)._validate_frequency(self, freq)
2032-
20331938
@classmethod
20341939
def _validate_dtype(cls, values, dtype):
20351940
raise AbstractMethodError(cls)

Diff for: pandas/core/arrays/datetimes.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class DatetimeArray(dtl.TimelikeOps, dtl.DatelikeOps): # type: ignore[misc]
186186
187187
Parameters
188188
----------
189-
values : Series, Index, DatetimeArray, ndarray
189+
data : Series, Index, DatetimeArray, ndarray
190190
The datetime data.
191191
192192
For DatetimeArray `values` (or a Series or Index boxing one),
@@ -287,7 +287,6 @@ def _scalar_type(self) -> type[Timestamp]:
287287

288288
_dtype: np.dtype[np.datetime64] | DatetimeTZDtype
289289
_freq: BaseOffset | None = None
290-
_default_dtype = DT64NS_DTYPE # used in TimeLikeOps.__init__
291290

292291
@classmethod
293292
def _from_scalars(cls, scalars, *, dtype: DtypeObj) -> Self:

Diff for: pandas/core/arrays/timedeltas.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class TimedeltaArray(dtl.TimelikeOps):
113113
114114
Parameters
115115
----------
116-
values : array-like
116+
data : array-like
117117
The timedelta data.
118118
119119
dtype : numpy.dtype
@@ -196,7 +196,6 @@ def dtype(self) -> np.dtype[np.timedelta64]: # type: ignore[override]
196196
# Constructors
197197

198198
_freq = None
199-
_default_dtype = TD64NS_DTYPE # used in TimeLikeOps.__init__
200199

201200
@classmethod
202201
def _validate_dtype(cls, values, dtype):

Diff for: pandas/tests/arrays/datetimes/test_constructors.py

-96
Original file line numberDiff line numberDiff line change
@@ -16,34 +16,6 @@ def test_from_sequence_invalid_type(self):
1616
with pytest.raises(TypeError, match="Cannot create a DatetimeArray"):
1717
DatetimeArray._from_sequence(mi, dtype="M8[ns]")
1818

19-
def test_only_1dim_accepted(self):
20-
arr = np.array([0, 1, 2, 3], dtype="M8[h]").astype("M8[ns]")
21-
22-
depr_msg = "DatetimeArray.__init__ is deprecated"
23-
with tm.assert_produces_warning(FutureWarning, match=depr_msg):
24-
with pytest.raises(ValueError, match="Only 1-dimensional"):
25-
# 3-dim, we allow 2D to sneak in for ops purposes GH#29853
26-
DatetimeArray(arr.reshape(2, 2, 1))
27-
28-
with tm.assert_produces_warning(FutureWarning, match=depr_msg):
29-
with pytest.raises(ValueError, match="Only 1-dimensional"):
30-
# 0-dim
31-
DatetimeArray(arr[[0]].squeeze())
32-
33-
def test_freq_validation(self):
34-
# GH#24623 check that invalid instances cannot be created with the
35-
# public constructor
36-
arr = np.arange(5, dtype=np.int64) * 3600 * 10**9
37-
38-
msg = (
39-
"Inferred frequency h from passed values does not "
40-
"conform to passed frequency W-SUN"
41-
)
42-
depr_msg = "DatetimeArray.__init__ is deprecated"
43-
with tm.assert_produces_warning(FutureWarning, match=depr_msg):
44-
with pytest.raises(ValueError, match=msg):
45-
DatetimeArray(arr, freq="W")
46-
4719
@pytest.mark.parametrize(
4820
"meth",
4921
[
@@ -76,42 +48,9 @@ def test_from_pandas_array(self):
7648
expected = pd.date_range("1970-01-01", periods=5, freq="h")._data
7749
tm.assert_datetime_array_equal(result, expected)
7850

79-
def test_mismatched_timezone_raises(self):
80-
depr_msg = "DatetimeArray.__init__ is deprecated"
81-
with tm.assert_produces_warning(FutureWarning, match=depr_msg):
82-
arr = DatetimeArray(
83-
np.array(["2000-01-01T06:00:00"], dtype="M8[ns]"),
84-
dtype=DatetimeTZDtype(tz="US/Central"),
85-
)
86-
dtype = DatetimeTZDtype(tz="US/Eastern")
87-
msg = r"dtype=datetime64\[ns.*\] does not match data dtype datetime64\[ns.*\]"
88-
with tm.assert_produces_warning(FutureWarning, match=depr_msg):
89-
with pytest.raises(TypeError, match=msg):
90-
DatetimeArray(arr, dtype=dtype)
91-
92-
# also with mismatched tzawareness
93-
with tm.assert_produces_warning(FutureWarning, match=depr_msg):
94-
with pytest.raises(TypeError, match=msg):
95-
DatetimeArray(arr, dtype=np.dtype("M8[ns]"))
96-
with tm.assert_produces_warning(FutureWarning, match=depr_msg):
97-
with pytest.raises(TypeError, match=msg):
98-
DatetimeArray(arr.tz_localize(None), dtype=arr.dtype)
99-
100-
def test_non_array_raises(self):
101-
depr_msg = "DatetimeArray.__init__ is deprecated"
102-
with tm.assert_produces_warning(FutureWarning, match=depr_msg):
103-
with pytest.raises(ValueError, match="list"):
104-
DatetimeArray([1, 2, 3])
105-
10651
def test_bool_dtype_raises(self):
10752
arr = np.array([1, 2, 3], dtype="bool")
10853

109-
depr_msg = "DatetimeArray.__init__ is deprecated"
110-
msg = "Unexpected value for 'dtype': 'bool'. Must be"
111-
with tm.assert_produces_warning(FutureWarning, match=depr_msg):
112-
with pytest.raises(ValueError, match=msg):
113-
DatetimeArray(arr)
114-
11554
msg = r"dtype bool cannot be converted to datetime64\[ns\]"
11655
with pytest.raises(TypeError, match=msg):
11756
DatetimeArray._from_sequence(arr, dtype="M8[ns]")
@@ -122,41 +61,6 @@ def test_bool_dtype_raises(self):
12261
with pytest.raises(TypeError, match=msg):
12362
pd.to_datetime(arr)
12463

125-
def test_incorrect_dtype_raises(self):
126-
depr_msg = "DatetimeArray.__init__ is deprecated"
127-
with tm.assert_produces_warning(FutureWarning, match=depr_msg):
128-
with pytest.raises(ValueError, match="Unexpected value for 'dtype'."):
129-
DatetimeArray(np.array([1, 2, 3], dtype="i8"), dtype="category")
130-
131-
with tm.assert_produces_warning(FutureWarning, match=depr_msg):
132-
with pytest.raises(ValueError, match="Unexpected value for 'dtype'."):
133-
DatetimeArray(np.array([1, 2, 3], dtype="i8"), dtype="m8[s]")
134-
135-
with tm.assert_produces_warning(FutureWarning, match=depr_msg):
136-
with pytest.raises(ValueError, match="Unexpected value for 'dtype'."):
137-
DatetimeArray(np.array([1, 2, 3], dtype="i8"), dtype="M8[D]")
138-
139-
def test_mismatched_values_dtype_units(self):
140-
arr = np.array([1, 2, 3], dtype="M8[s]")
141-
dtype = np.dtype("M8[ns]")
142-
msg = "Values resolution does not match dtype."
143-
depr_msg = "DatetimeArray.__init__ is deprecated"
144-
145-
with tm.assert_produces_warning(FutureWarning, match=depr_msg):
146-
with pytest.raises(ValueError, match=msg):
147-
DatetimeArray(arr, dtype=dtype)
148-
149-
dtype2 = DatetimeTZDtype(tz="UTC", unit="ns")
150-
with tm.assert_produces_warning(FutureWarning, match=depr_msg):
151-
with pytest.raises(ValueError, match=msg):
152-
DatetimeArray(arr, dtype=dtype2)
153-
154-
def test_freq_infer_raises(self):
155-
depr_msg = "DatetimeArray.__init__ is deprecated"
156-
with tm.assert_produces_warning(FutureWarning, match=depr_msg):
157-
with pytest.raises(ValueError, match="Frequency inference"):
158-
DatetimeArray(np.array([1, 2, 3], dtype="i8"), freq="infer")
159-
16064
def test_copy(self):
16165
data = np.array([1, 2, 3], dtype="M8[ns]")
16266
arr = DatetimeArray._from_sequence(data, copy=False)

Diff for: pandas/tests/arrays/test_datetimelike.py

-6
Original file line numberDiff line numberDiff line change
@@ -1320,12 +1320,6 @@ def test_from_pandas_array(dtype):
13201320

13211321
cls = {"M8[ns]": DatetimeArray, "m8[ns]": TimedeltaArray}[dtype]
13221322

1323-
depr_msg = f"{cls.__name__}.__init__ is deprecated"
1324-
with tm.assert_produces_warning(FutureWarning, match=depr_msg):
1325-
result = cls(arr)
1326-
expected = cls(data)
1327-
tm.assert_extension_array_equal(result, expected)
1328-
13291323
result = cls._from_sequence(arr, dtype=dtype)
13301324
expected = cls._from_sequence(data, dtype=dtype)
13311325
tm.assert_extension_array_equal(result, expected)

0 commit comments

Comments
 (0)