Skip to content

Commit

Permalink
BUG: Output the datetime64 dtype to the pickle format from 1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
mwiebe authored and charris committed May 10, 2012
1 parent e686b36 commit b7cb21a
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions numpy/core/src/multiarray/descriptor.c
Original file line number Diff line number Diff line change
Expand Up @@ -2091,8 +2091,7 @@ _get_pickleabletype_from_datetime_metadata(PyArray_Descr *dtype)
Py_INCREF(dtype->metadata);
PyTuple_SET_ITEM(ret, 0, dtype->metadata);
} else {
Py_INCREF(Py_None);
PyTuple_SET_ITEM(ret, 0, Py_None);
PyTuple_SET_ITEM(ret, 0, PyDict_New());
}

/* Convert the datetime metadata into a tuple */
Expand All @@ -2101,11 +2100,21 @@ _get_pickleabletype_from_datetime_metadata(PyArray_Descr *dtype)
Py_DECREF(ret);
return NULL;
}
dt_tuple = convert_datetime_metadata_to_tuple(meta);
/* Use a 4-tuple that numpy 1.6 knows how to unpickle */
dt_tuple = PyTuple_New(4);
if (dt_tuple == NULL) {
Py_DECREF(ret);
return NULL;
}
PyTuple_SET_ITEM(dt_tuple, 0,
PyBytes_FromString(_datetime_strings[meta->base]));
PyTuple_SET_ITEM(dt_tuple, 1,
PyInt_FromLong(meta->num));
PyTuple_SET_ITEM(dt_tuple, 2,
PyInt_FromLong(1));
PyTuple_SET_ITEM(dt_tuple, 3,
PyInt_FromLong(1));

PyTuple_SET_ITEM(ret, 1, dt_tuple);

return ret;
Expand Down

0 comments on commit b7cb21a

Please sign in to comment.