Skip to content

Commit a6e0b79

Browse files
WillAydproost
authored andcommitted
Removed is_sparse_array from objToJSON (pandas-dev#30136)
1 parent e68873c commit a6e0b79

File tree

1 file changed

+3
-20
lines changed

1 file changed

+3
-20
lines changed

pandas/_libs/src/ujson/python/objToJSON.c

+3-20
Original file line numberDiff line numberDiff line change
@@ -212,36 +212,19 @@ static TypeContext *createTypeContext(void) {
212212
return pc;
213213
}
214214

215-
static int is_sparse_array(PyObject *obj) {
216-
// TODO can be removed again once SparseArray.values is removed (GH26421)
217-
if (PyObject_HasAttrString(obj, "_subtyp")) {
218-
PyObject *_subtype = PyObject_GetAttrString(obj, "_subtyp");
219-
PyObject *sparse_array = PyUnicode_FromString("sparse_array");
220-
int ret = PyUnicode_Compare(_subtype, sparse_array);
221-
222-
if (ret == 0) {
223-
return 1;
224-
}
225-
}
226-
return 0;
227-
}
228-
229215
static PyObject *get_values(PyObject *obj) {
230216
PyObject *values = NULL;
231217

232-
if (!is_sparse_array(obj)) {
233-
values = PyObject_GetAttrString(obj, "values");
234-
PRINTMARK();
235-
}
218+
values = PyObject_GetAttrString(obj, "values");
219+
PRINTMARK();
236220

237221
if (values && !PyArray_CheckExact(values)) {
238222

239223
if (PyObject_HasAttrString(values, "to_numpy")) {
240224
values = PyObject_CallMethod(values, "to_numpy", NULL);
241225
}
242226

243-
if (!is_sparse_array(values) &&
244-
PyObject_HasAttrString(values, "values")) {
227+
if (PyObject_HasAttrString(values, "values")) {
245228
PyObject *subvals = get_values(values);
246229
PyErr_Clear();
247230
PRINTMARK();

0 commit comments

Comments
 (0)