CLN: remove check_series_type (#32513) · pandas-dev/pandas@08c6597 (original) (raw)
`@@ -34,6 +34,7 @@
`
34
34
`is_interval_dtype,
`
35
35
`is_list_like,
`
36
36
`is_number,
`
``
37
`+
is_numeric_dtype,
`
37
38
`is_period_dtype,
`
38
39
`is_sequence,
`
39
40
`is_timedelta64_dtype,
`
`@@ -1064,7 +1065,6 @@ def assert_series_equal(
`
1064
1065
`right,
`
1065
1066
`check_dtype=True,
`
1066
1067
`check_index_type="equiv",
`
1067
``
`-
check_series_type=True,
`
1068
1068
`check_less_precise=False,
`
1069
1069
`check_names=True,
`
1070
1070
`check_exact=False,
`
`@@ -1085,8 +1085,6 @@ def assert_series_equal(
`
1085
1085
` check_index_type : bool or {'equiv'}, default 'equiv'
`
1086
1086
` Whether to check the Index class, dtype and inferred_type
`
1087
1087
` are identical.
`
1088
``
`-
check_series_type : bool, default True
`
1089
``
`-
Whether to check the Series class is identical.
`
1090
1088
` check_less_precise : bool or int, default False
`
1091
1089
` Specify comparison precision. Only used when check_exact is False.
`
1092
1090
` 5 digits (False) or 3 digits (True) after decimal points are compared.
`
`@@ -1118,11 +1116,10 @@ def assert_series_equal(
`
1118
1116
`# instance validation
`
1119
1117
`_check_isinstance(left, right, Series)
`
1120
1118
``
1121
``
`-
if check_series_type:
`
1122
``
`-
ToDo: There are some tests using rhs is sparse
`
1123
``
`-
lhs is dense. Should use assert_class_equal in future
`
1124
``
`-
assert isinstance(left, type(right))
`
1125
``
`-
assert_class_equal(left, right, obj=obj)
`
``
1119
`+
TODO: There are some tests using rhs is sparse
`
``
1120
`+
lhs is dense. Should use assert_class_equal in future
`
``
1121
`+
assert isinstance(left, type(right))
`
``
1122
`+
assert_class_equal(left, right, obj=obj)
`
1126
1123
``
1127
1124
`# length comparison
`
1128
1125
`if len(left) != len(right):
`
`@@ -1147,47 +1144,40 @@ def assert_series_equal(
`
1147
1144
`` # is False. We'll still raise if only one is a Categorical
,
``
1148
1145
`` # regardless of check_categorical
``
1149
1146
`if (
`
1150
``
`-
is_categorical_dtype(left)
`
1151
``
`-
and is_categorical_dtype(right)
`
``
1147
`+
is_categorical_dtype(left.dtype)
`
``
1148
`+
and is_categorical_dtype(right.dtype)
`
1152
1149
`and not check_categorical
`
1153
1150
` ):
`
1154
1151
`pass
`
1155
1152
`else:
`
1156
1153
`assert_attr_equal("dtype", left, right, obj=f"Attributes of {obj}")
`
1157
1154
``
1158
1155
`if check_exact:
`
``
1156
`+
if not is_numeric_dtype(left.dtype):
`
``
1157
`+
raise AssertionError("check_exact may only be used with numeric Series")
`
``
1158
+
1159
1159
`assert_numpy_array_equal(
`
1160
``
`-
left._internal_get_values(),
`
1161
``
`-
right._internal_get_values(),
`
1162
``
`-
check_dtype=check_dtype,
`
1163
``
`-
obj=str(obj),
`
``
1160
`+
left._values, right._values, check_dtype=check_dtype, obj=str(obj)
`
1164
1161
` )
`
1165
``
`-
elif check_datetimelike_compat:
`
``
1162
`+
elif check_datetimelike_compat and (
`
``
1163
`+
needs_i8_conversion(left.dtype) or needs_i8_conversion(right.dtype)
`
``
1164
`+
):
`
1166
1165
`# we want to check only if we have compat dtypes
`
1167
1166
`# e.g. integer and M|m are NOT compat, but we can simply check
`
1168
1167
`# the values in that case
`
1169
``
`-
if needs_i8_conversion(left) or needs_i8_conversion(right):
`
1170
``
-
1171
``
`-
datetimelike may have different objects (e.g. datetime.datetime
`
1172
``
`-
vs Timestamp) but will compare equal
`
1173
``
`-
if not Index(left._values).equals(Index(right._values)):
`
1174
``
`-
msg = (
`
1175
``
`-
f"[datetimelike_compat=True] {left._values} "
`
1176
``
`-
f"is not equal to {right._values}."
`
1177
``
`-
)
`
1178
``
`-
raise AssertionError(msg)
`
1179
``
`-
else:
`
1180
``
`-
assert_numpy_array_equal(
`
1181
``
`-
left._internal_get_values(),
`
1182
``
`-
right._internal_get_values(),
`
1183
``
`-
check_dtype=check_dtype,
`
``
1168
+
``
1169
`+
datetimelike may have different objects (e.g. datetime.datetime
`
``
1170
`+
vs Timestamp) but will compare equal
`
``
1171
`+
if not Index(left._values).equals(Index(right._values)):
`
``
1172
`+
msg = (
`
``
1173
`+
f"[datetimelike_compat=True] {left._values} "
`
``
1174
`+
f"is not equal to {right._values}."
`
1184
1175
` )
`
1185
``
`-
elif is_interval_dtype(left) or is_interval_dtype(right):
`
``
1176
`+
raise AssertionError(msg)
`
``
1177
`+
elif is_interval_dtype(left.dtype) or is_interval_dtype(right.dtype):
`
1186
1178
`assert_interval_array_equal(left.array, right.array)
`
1187
``
`-
elif is_extension_array_dtype(left.dtype) and is_datetime64tz_dtype(left.dtype):
`
``
1179
`+
elif is_datetime64tz_dtype(left.dtype):
`
1188
1180
`# .values is an ndarray, but ._values is the ExtensionArray.
`
1189
``
`-
TODO: Use .array
`
1190
``
`-
assert is_extension_array_dtype(right.dtype)
`
1191
1181
`assert_extension_array_equal(left._values, right._values)
`
1192
1182
`elif (
`
1193
1183
`is_extension_array_dtype(left)
`