Skip to content

Commit c028455

Browse files
committed
Move Timestamp dtype to test_ file
1 parent ea59283 commit c028455

File tree

2 files changed

+35
-32
lines changed

2 files changed

+35
-32
lines changed

pandas/tests/extension/arrow/arrays.py

-31
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
current implementation is not efficient.
88
"""
99
import copy
10-
import datetime
1110
import itertools
1211
import operator
1312
from typing import Type
@@ -68,26 +67,6 @@ def construct_array_type(cls) -> Type["ArrowStringArray"]:
6867
return ArrowStringArray
6968

7069

71-
@register_extension_dtype
72-
class ArrowTimestampUSDtype(ExtensionDtype):
73-
74-
type = datetime.datetime
75-
kind = "M"
76-
name = "arrow_timestamp_us"
77-
na_value = pa.NULL
78-
79-
@classmethod
80-
def construct_array_type(cls) -> Type["ArrowTimestampUSArray"]:
81-
"""
82-
Return the array type associated with this dtype.
83-
84-
Returns
85-
-------
86-
type
87-
"""
88-
return ArrowTimestampUSArray
89-
90-
9170
class ArrowExtensionArray(ExtensionArray):
9271
@classmethod
9372
def from_scalars(cls, values):
@@ -222,13 +201,3 @@ def __init__(self, values):
222201
assert values.type == pa.string()
223202
self._data = values
224203
self._dtype = ArrowStringDtype()
225-
226-
227-
class ArrowTimestampUSArray(ArrowExtensionArray):
228-
def __init__(self, values):
229-
if not isinstance(values, pa.ChunkedArray):
230-
raise ValueError
231-
232-
assert values.type == pa.timestamp("us")
233-
self._data = values
234-
self._dtype = ArrowTimestampUSDtype()

pandas/tests/extension/arrow/test_timestamp.py

+35-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,46 @@
11
import datetime
2+
from typing import Type
23

34
import pytest
45

56
import pandas as pd
7+
from pandas.api.extensions import ExtensionDtype, register_extension_dtype
68

79
pytest.importorskip("pyarrow", minversion="0.13.0")
810

9-
from .arrays import ArrowTimestampUSArray # isort:skip
11+
import pyarrow as pa # isort:skip
12+
13+
from .arrays import ArrowExtensionArray # isort:skip
14+
15+
16+
@register_extension_dtype
17+
class ArrowTimestampUSDtype(ExtensionDtype):
18+
19+
type = datetime.datetime
20+
kind = "M"
21+
name = "arrow_timestamp_us"
22+
na_value = pa.NULL
23+
24+
@classmethod
25+
def construct_array_type(cls) -> Type["ArrowTimestampUSArray"]:
26+
"""
27+
Return the array type associated with this dtype.
28+
29+
Returns
30+
-------
31+
type
32+
"""
33+
return ArrowTimestampUSArray
34+
35+
36+
class ArrowTimestampUSArray(ArrowExtensionArray):
37+
def __init__(self, values):
38+
if not isinstance(values, pa.ChunkedArray):
39+
raise ValueError
40+
41+
assert values.type == pa.timestamp("us")
42+
self._data = values
43+
self._dtype = ArrowTimestampUSDtype()
1044

1145

1246
@pytest.mark.xfail(

0 commit comments

Comments
 (0)