Fix the numpy ndarray subclass serialization bug (#7392)

This commit is contained in:
Siyuan (Ryans) Zhuang
2020-03-01 23:05:59 -08:00
committed by GitHub
parent 48cdca843f
commit 0792b5cb93
2 changed files with 52 additions and 2 deletions
+2 -2
View File
@@ -541,8 +541,8 @@ class CloudPickler(Pickler):
# This is a patch for python3.5
if isinstance(obj, numpy.ndarray):
if (self.proto < 5 or
(not obj.flags.c_contiguous and
not obj.flags.f_contiguous) or
(not obj.flags.c_contiguous and not obj.flags.f_contiguous) or
(issubclass(type(obj), numpy.ndarray) and type(obj) is not numpy.ndarray) or
obj.dtype == "O" or obj.itemsize == 0):
return NotImplemented
return _numpy_ndarray_reduce(obj)