Skip to content

Commit

Permalink
Moved dtypes
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAugspurger committed Feb 9, 2018
1 parent 87583dc commit d136227
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 31 deletions.
32 changes: 1 addition & 31 deletions pandas/tests/dtypes/test_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@
Series, Categorical, CategoricalIndex, IntervalIndex, date_range)

from pandas.compat import string_types
from pandas.core.arrays import ExtensionArray
from pandas.core.dtypes.dtypes import (
DatetimeTZDtype, PeriodDtype,
IntervalDtype, CategoricalDtype, ExtensionDtype)
IntervalDtype, CategoricalDtype)
from pandas.core.dtypes.common import (
is_categorical_dtype, is_categorical,
is_datetime64tz_dtype, is_datetimetz,
is_extension_array_dtype,
is_period_dtype, is_period,
is_dtype_equal, is_datetime64_ns_dtype,
is_datetime64_dtype, is_interval_dtype,
Expand Down Expand Up @@ -744,31 +742,3 @@ def test_categorical_categories(self):
tm.assert_index_equal(c1.categories, pd.Index(['a', 'b']))
c1 = CategoricalDtype(CategoricalIndex(['a', 'b']))
tm.assert_index_equal(c1.categories, pd.Index(['a', 'b']))


class DummyArray(ExtensionArray):
pass


class DummyDtype(ExtensionDtype):
pass


class TestExtensionArrayDtype(object):

@pytest.mark.parametrize('values', [
pd.Categorical([]),
pd.Categorical([]).dtype,
pd.Series(pd.Categorical([])),
DummyDtype(),
DummyArray(),
])
def test_is_extension_array_dtype(self, values):
assert is_extension_array_dtype(values)

@pytest.mark.parametrize('values', [
np.array([]),
pd.Series(np.array([])),
])
def test_is_not_extension_array_dtype(self, values):
assert not is_extension_array_dtype(values)
29 changes: 29 additions & 0 deletions pandas/tests/extension/test_common.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import numpy as np
import pytest

import pandas as pd
import pandas.util.testing as tm
from pandas.core.arrays import ExtensionArray
from pandas.core.dtypes.common import is_extension_array_dtype
from pandas.core.dtypes.dtypes import ExtensionDtype


class DummyDtype(ExtensionDtype):
pass


class DummyArray(ExtensionArray):
Expand All @@ -17,7 +25,28 @@ def dtype(self):
return self.data.dtype


class TestExtensionArrayDtype(object):

@pytest.mark.parametrize('values', [
pd.Categorical([]),
pd.Categorical([]).dtype,
pd.Series(pd.Categorical([])),
DummyDtype(),
DummyArray(np.array([1, 2])),
])
def test_is_extension_array_dtype(self, values):
assert is_extension_array_dtype(values)

@pytest.mark.parametrize('values', [
np.array([]),
pd.Series(np.array([])),
])
def test_is_not_extension_array_dtype(self, values):
assert not is_extension_array_dtype(values)


def test_astype():

arr = DummyArray(np.array([1, 2, 3]))
expected = np.array([1, 2, 3], dtype=object)

Expand Down

0 comments on commit d136227

Please sign in to comment.