From 70d0ce2610419ef9fd88b048b4e685a39986c1cc Mon Sep 17 00:00:00 2001 From: tp Date: Wed, 12 Jul 2017 23:41:32 +0100 Subject: [PATCH 1/3] Added test for _get_dtype_type. --- pandas/tests/dtypes/test_common.py | 34 ++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/pandas/tests/dtypes/test_common.py b/pandas/tests/dtypes/test_common.py index 290cdd732b6d6..c255b6952bfe3 100644 --- a/pandas/tests/dtypes/test_common.py +++ b/pandas/tests/dtypes/test_common.py @@ -568,3 +568,37 @@ def test__get_dtype(input_param, result): def test__get_dtype_fails(input_param): # python objects pytest.raises(TypeError, com._get_dtype, input_param) + + +@pytest.mark.parametrize('input_param,result', [ + (int, np.dtype(int).type), + ('int32', np.int32), + (float, np.dtype(float).type), + ('float64', np.float64), + (np.dtype('float64'), np.float64), + (str, np.dtype(str).type), + (pd.Series([1, 2], dtype=np.dtype('int16')), np.int16), + (pd.Series(['a', 'b']), np.object_), + (pd.Index([1, 2], dtype='int64'), np.int64), + (pd.Index(['a', 'b']), np.object_), + ('category', com.CategoricalDtypeType), + (pd.Categorical(['a', 'b']).dtype, com.CategoricalDtypeType), + (pd.Categorical(['a', 'b']), com.CategoricalDtypeType), + (pd.CategoricalIndex(['a', 'b']).dtype, com.CategoricalDtypeType), + (pd.CategoricalIndex(['a', 'b']), com.CategoricalDtypeType), + (pd.DatetimeIndex([1, 2]), np.datetime64), + (pd.DatetimeIndex([1, 2]).dtype, np.datetime64), + (' Date: Thu, 13 Jul 2017 00:52:42 +0100 Subject: [PATCH 2/3] Added test for DateTimeIndex with timezone. --- pandas/tests/dtypes/test_common.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandas/tests/dtypes/test_common.py b/pandas/tests/dtypes/test_common.py index c255b6952bfe3..b35216eb46ca8 100644 --- a/pandas/tests/dtypes/test_common.py +++ b/pandas/tests/dtypes/test_common.py @@ -589,6 +589,8 @@ def test__get_dtype_fails(input_param): (pd.DatetimeIndex([1, 2]), np.datetime64), (pd.DatetimeIndex([1, 2]).dtype, np.datetime64), (' Date: Thu, 20 Jul 2017 12:59:06 +0100 Subject: [PATCH 3/3] pep8 cleanup --- pandas/tests/dtypes/test_common.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandas/tests/dtypes/test_common.py b/pandas/tests/dtypes/test_common.py index b35216eb46ca8..b02691e957366 100644 --- a/pandas/tests/dtypes/test_common.py +++ b/pandas/tests/dtypes/test_common.py @@ -590,7 +590,8 @@ def test__get_dtype_fails(input_param): (pd.DatetimeIndex([1, 2]).dtype, np.datetime64), ('