From 4dd071e4f456703194b2238e958259d6fb85292a Mon Sep 17 00:00:00 2001 From: Artem Vorobyev <44067777+SecretLake@users.noreply.github.com> Date: Sun, 23 Apr 2023 14:20:28 +0200 Subject: [PATCH] Test dir of pandas.api.* (#52826) --- pandas/tests/api/test_api.py | 96 ++++++++++++++++++++++++++++++++++-- 1 file changed, 93 insertions(+), 3 deletions(-) diff --git a/pandas/tests/api/test_api.py b/pandas/tests/api/test_api.py index c2e89a2db12ee..73713de08473b 100644 --- a/pandas/tests/api/test_api.py +++ b/pandas/tests/api/test_api.py @@ -5,7 +5,13 @@ import pandas as pd from pandas import api import pandas._testing as tm -from pandas.api import typing as api_typing +from pandas.api import ( + extensions as api_extensions, + indexers as api_indexers, + interchange as api_interchange, + types as api_types, + typing as api_typing, +) class Base: @@ -237,7 +243,13 @@ def test_depr(self): class TestApi(Base): - allowed = ["types", "extensions", "indexers", "interchange", "typing"] + allowed_api_dirs = [ + "types", + "extensions", + "indexers", + "interchange", + "typing", + ] allowed_typing = [ "DataFrameGroupBy", "DatetimeIndexResamplerGroupby", @@ -256,13 +268,91 @@ class TestApi(Base): "TimeGrouper", "Window", ] + allowed_api_types = [ + "is_any_real_numeric_dtype", + "is_array_like", + "is_bool", + "is_bool_dtype", + "is_categorical_dtype", + "is_complex", + "is_complex_dtype", + "is_datetime64_any_dtype", + "is_datetime64_dtype", + "is_datetime64_ns_dtype", + "is_datetime64tz_dtype", + "is_dict_like", + "is_dtype_equal", + "is_extension_array_dtype", + "is_file_like", + "is_float", + "is_float_dtype", + "is_hashable", + "is_int64_dtype", + "is_integer", + "is_integer_dtype", + "is_interval", + "is_interval_dtype", + "is_iterator", + "is_list_like", + "is_named_tuple", + "is_number", + "is_numeric_dtype", + "is_object_dtype", + "is_period_dtype", + "is_re", + "is_re_compilable", + "is_scalar", + "is_signed_integer_dtype", + "is_sparse", + "is_string_dtype", + "is_timedelta64_dtype", + "is_timedelta64_ns_dtype", + "is_unsigned_integer_dtype", + "pandas_dtype", + "infer_dtype", + "union_categoricals", + "CategoricalDtype", + "DatetimeTZDtype", + "IntervalDtype", + "PeriodDtype", + ] + allowed_api_interchange = ["from_dataframe", "DataFrame"] + allowed_api_indexers = [ + "check_array_indexer", + "BaseIndexer", + "FixedForwardWindowIndexer", + "VariableOffsetWindowIndexer", + ] + allowed_api_extensions = [ + "no_default", + "ExtensionDtype", + "register_extension_dtype", + "register_dataframe_accessor", + "register_index_accessor", + "register_series_accessor", + "take", + "ExtensionArray", + "ExtensionScalarOpsMixin", + ] def test_api(self): - self.check(api, self.allowed) + self.check(api, self.allowed_api_dirs) def test_api_typing(self): self.check(api_typing, self.allowed_typing) + def test_api_types(self): + self.check(api_types, self.allowed_api_types) + + def test_api_interchange(self): + self.check(api_interchange, self.allowed_api_interchange) + + def test_api_indexers(self): + self.check(api_indexers, self.allowed_api_indexers) + + def test_api_extensions(self): + self.check(api_extensions, self.allowed_api_extensions) + class TestTesting(Base): funcs = [