forked from pandas-dev/pandas
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest_api.py
86 lines (70 loc) · 2.12 KB
/
test_api.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
"""
Tests for the pseudo-public API implemented in internals/api.py and exposed
in core.internals
"""
import pytest
import pandas as pd
import pandas._testing as tm
from pandas.core import internals
from pandas.core.internals import api
def test_internals_api():
assert internals.make_block is api.make_block
def test_namespace():
# SUBJECT TO CHANGE
modules = [
"blocks",
"concat",
"managers",
"construction",
"array_manager",
"base",
"api",
"ops",
]
expected = [
"make_block",
"DataManager",
"ArrayManager",
"BlockManager",
"SingleDataManager",
"SingleBlockManager",
"SingleArrayManager",
"concatenate_managers",
]
result = [x for x in dir(internals) if not x.startswith("__")]
assert set(result) == set(expected + modules)
@pytest.mark.parametrize(
"name",
[
"NumericBlock",
"ObjectBlock",
"Block",
"ExtensionBlock",
"DatetimeTZBlock",
],
)
def test_deprecations(name):
# GH#55139
msg = f"{name} is deprecated.* Use public APIs instead"
with tm.assert_produces_warning(DeprecationWarning, match=msg):
getattr(internals, name)
if name not in ["NumericBlock", "ObjectBlock"]:
# NumericBlock and ObjectBlock are not in the internals.api namespace
with tm.assert_produces_warning(DeprecationWarning, match=msg):
getattr(api, name)
def test_make_block_2d_with_dti():
# GH#41168
dti = pd.date_range("2012", periods=3, tz="UTC")
blk = api.make_block(dti, placement=[0])
assert blk.shape == (1, 3)
assert blk.values.shape == (1, 3)
def test_create_block_manager_from_blocks_deprecated():
# GH#33892
# If they must, downstream packages should get this from internals.api,
# not internals.
msg = (
"create_block_manager_from_blocks is deprecated and will be "
"removed in a future version. Use public APIs instead"
)
with tm.assert_produces_warning(DeprecationWarning, match=msg):
internals.create_block_manager_from_blocks