|
7 | 7 | import copy |
8 | 8 | import io |
9 | 9 | import pickle as pkl |
10 | | -from typing import ( |
11 | | - TYPE_CHECKING, |
12 | | - Generator, |
13 | | -) |
14 | | -import warnings |
| 10 | +from typing import Generator |
15 | 11 |
|
16 | 12 | import numpy as np |
17 | 13 |
|
|
26 | 22 | ) |
27 | 23 | from pandas.core.internals import BlockManager |
28 | 24 |
|
29 | | -if TYPE_CHECKING: |
30 | | - from pandas import ( |
31 | | - DataFrame, |
32 | | - Series, |
33 | | - ) |
34 | | - |
35 | 25 |
|
36 | 26 | def load_reduce(self): |
37 | 27 | stack = self.stack |
@@ -68,49 +58,6 @@ def load_reduce(self): |
68 | 58 | raise |
69 | 59 |
|
70 | 60 |
|
71 | | -_sparse_msg = """\ |
72 | | -
|
73 | | -Loading a saved '{cls}' as a {new} with sparse values. |
74 | | -'{cls}' is now removed. You should re-save this dataset in its new format. |
75 | | -""" |
76 | | - |
77 | | - |
78 | | -class _LoadSparseSeries: |
79 | | - # To load a SparseSeries as a Series[Sparse] |
80 | | - |
81 | | - # https://github.com/python/mypy/issues/1020 |
82 | | - # error: Incompatible return type for "__new__" (returns "Series", but must return |
83 | | - # a subtype of "_LoadSparseSeries") |
84 | | - def __new__(cls) -> Series: # type: ignore[misc] |
85 | | - from pandas import Series |
86 | | - |
87 | | - warnings.warn( |
88 | | - _sparse_msg.format(cls="SparseSeries", new="Series"), |
89 | | - FutureWarning, |
90 | | - stacklevel=6, |
91 | | - ) |
92 | | - |
93 | | - return Series(dtype=object) |
94 | | - |
95 | | - |
96 | | -class _LoadSparseFrame: |
97 | | - # To load a SparseDataFrame as a DataFrame[Sparse] |
98 | | - |
99 | | - # https://github.com/python/mypy/issues/1020 |
100 | | - # error: Incompatible return type for "__new__" (returns "DataFrame", but must |
101 | | - # return a subtype of "_LoadSparseFrame") |
102 | | - def __new__(cls) -> DataFrame: # type: ignore[misc] |
103 | | - from pandas import DataFrame |
104 | | - |
105 | | - warnings.warn( |
106 | | - _sparse_msg.format(cls="SparseDataFrame", new="DataFrame"), |
107 | | - FutureWarning, |
108 | | - stacklevel=6, |
109 | | - ) |
110 | | - |
111 | | - return DataFrame() |
112 | | - |
113 | | - |
114 | 61 | # If classes are moved, provide compat here. |
115 | 62 | _class_locations_map = { |
116 | 63 | ("pandas.core.sparse.array", "SparseArray"): ("pandas.core.arrays", "SparseArray"), |
@@ -144,14 +91,6 @@ def __new__(cls) -> DataFrame: # type: ignore[misc] |
144 | 91 | "pandas.core.arrays.sparse", |
145 | 92 | "SparseArray", |
146 | 93 | ), |
147 | | - ("pandas.sparse.series", "SparseSeries"): ( |
148 | | - "pandas.compat.pickle_compat", |
149 | | - "_LoadSparseSeries", |
150 | | - ), |
151 | | - ("pandas.sparse.frame", "SparseDataFrame"): ( |
152 | | - "pandas.core.sparse.frame", |
153 | | - "_LoadSparseFrame", |
154 | | - ), |
155 | 94 | ("pandas.indexes.base", "_new_Index"): ("pandas.core.indexes.base", "_new_Index"), |
156 | 95 | ("pandas.indexes.base", "Index"): ("pandas.core.indexes.base", "Index"), |
157 | 96 | ("pandas.indexes.numeric", "Int64Index"): ( |
@@ -183,14 +122,6 @@ def __new__(cls) -> DataFrame: # type: ignore[misc] |
183 | 122 | "pandas.core.indexes.numeric", |
184 | 123 | "Float64Index", |
185 | 124 | ), |
186 | | - ("pandas.core.sparse.series", "SparseSeries"): ( |
187 | | - "pandas.compat.pickle_compat", |
188 | | - "_LoadSparseSeries", |
189 | | - ), |
190 | | - ("pandas.core.sparse.frame", "SparseDataFrame"): ( |
191 | | - "pandas.compat.pickle_compat", |
192 | | - "_LoadSparseFrame", |
193 | | - ), |
194 | 125 | } |
195 | 126 |
|
196 | 127 |
|
|
0 commit comments