|
1 | 1 | import decimal
|
2 | 2 |
|
3 | 3 | import numpy as np
|
4 |
| -import pytest |
5 | 4 |
|
6 |
| -import pandas as pd |
7 |
| -import pandas.util.testing as tm |
8 | 5 | from pandas.core.dtypes.dtypes import registry
|
| 6 | + |
| 7 | +import pandas as pd |
9 | 8 | from pandas.api.extensions import register_extension_dtype
|
10 |
| -from pandas.core.arrays import period_array, integer_array |
| 9 | +from pandas.core.arrays import integer_array, period_array |
11 | 10 | from pandas.tests.extension.decimal import (
|
12 |
| - to_decimal, DecimalArray, DecimalDtype |
13 |
| -) |
| 11 | + DecimalArray, DecimalDtype, to_decimal) |
| 12 | +import pandas.util.testing as tm |
| 13 | +import pytest |
14 | 14 |
|
15 | 15 |
|
16 | 16 | @pytest.mark.parametrize("data, dtype, expected", [
|
@@ -38,6 +38,22 @@ def test_array(data, dtype, expected):
|
38 | 38 | tm.assert_equal(result, expected)
|
39 | 39 |
|
40 | 40 |
|
| 41 | +@pytest.mark.parametrize('data, expected', [ |
| 42 | + ([pd.Period("2000", "D"), pd.Period("2001", "D")], |
| 43 | + period_array(["2000", "2001"], freq="D")), |
| 44 | +]) |
| 45 | +def test_array_inference(data, expected): |
| 46 | + result = pd.array(data) |
| 47 | + tm.assert_equal(result, expected) |
| 48 | + |
| 49 | + |
| 50 | +def test_array_inference_period_fails(): |
| 51 | + data = [pd.Period("2000", "D"), pd.Period("2001", "A")] |
| 52 | + result = pd.array(data) |
| 53 | + expected = np.array(data, dtype=object) |
| 54 | + tm.assert_numpy_array_equal(result, expected) |
| 55 | + |
| 56 | + |
41 | 57 | # ---------------------------------------------------------------------------
|
42 | 58 | # A couple dummy classes to ensure that Series and Indexes are unboxed before
|
43 | 59 | # getting to the EA classes.
|
|
0 commit comments