|
| 1 | +from typing import Type |
| 2 | + |
1 | 3 | import numpy as np |
2 | 4 | import pandas as pd |
| 5 | +from pandas.api.extensions import ExtensionDtype |
3 | 6 | import pandas.api.types as api |
4 | 7 | from typing_extensions import assert_type |
5 | 8 |
|
@@ -176,3 +179,28 @@ def test_infer_dtype() -> None: |
176 | 179 | def test_union_categoricals() -> None: |
177 | 180 | to_union = [pd.Categorical([1, 2, 3]), pd.Categorical([3, 4, 5])] |
178 | 181 | check(assert_type(api.union_categoricals(to_union), pd.Categorical), pd.Categorical) |
| 182 | + |
| 183 | + |
| 184 | +def check_extension_dtypes() -> None: |
| 185 | + # GH 315 |
| 186 | + def check_ext_dtype(etype: Type[ExtensionDtype]): |
| 187 | + assert issubclass(etype, ExtensionDtype) |
| 188 | + |
| 189 | + check_ext_dtype(pd.Int64Dtype) |
| 190 | + check_ext_dtype(pd.Int8Dtype) |
| 191 | + check_ext_dtype(pd.Int16Dtype) |
| 192 | + check_ext_dtype(pd.Int32Dtype) |
| 193 | + check_ext_dtype(pd.Int64Dtype) |
| 194 | + check_ext_dtype(pd.UInt8Dtype) |
| 195 | + check_ext_dtype(pd.UInt16Dtype) |
| 196 | + check_ext_dtype(pd.UInt32Dtype) |
| 197 | + check_ext_dtype(pd.UInt64Dtype) |
| 198 | + check_ext_dtype(pd.BooleanDtype) |
| 199 | + check_ext_dtype(pd.StringDtype) |
| 200 | + check_ext_dtype(pd.CategoricalDtype) |
| 201 | + check_ext_dtype(pd.DatetimeTZDtype) |
| 202 | + check_ext_dtype(pd.IntervalDtype) |
| 203 | + check_ext_dtype(pd.PeriodDtype) |
| 204 | + check_ext_dtype(pd.SparseDtype) |
| 205 | + check_ext_dtype(pd.Float32Dtype) |
| 206 | + check_ext_dtype(pd.Float64Dtype) |
0 commit comments