Fixed cloudpickle breaking

This commit is contained in:
Patrick Kidger
2023-03-02 12:35:38 -08:00
parent 8c86958b77
commit 2b339715f9
3 changed files with 27 additions and 12 deletions
+18 -12
View File
@@ -185,20 +185,26 @@ def _check_dims(
class _MetaAbstractArray(type):
def __eq__(self, other):
if type(self) is not type(other):
return False
if self.array_type is not other.array_type:
return False
if self.dtypes != other.dtypes:
return False
if self.dims != other.dims:
return False
if self.index_variadic != other.index_variadic:
return False
return True
if self is AbstractArray:
return other is AbstractArray
else:
if type(self) is not type(other):
return False
if self.array_type is not other.array_type:
return False
if self.dtypes != other.dtypes:
return False
if self.dims != other.dims:
return False
if self.index_variadic != other.index_variadic:
return False
return True
def __hash__(self):
return hash((self.array_type, self.dtypes, self.dims, self.index_variadic))
if self is AbstractArray:
return 0
else:
return hash((self.array_type, self.dtypes, self.dims, self.index_variadic))
def __instancecheck__(cls, obj):
if not isinstance(obj, cls.array_type):
+1
View File
@@ -2,3 +2,4 @@ equinox>=0.5.3
pytest>=7.0.1
beartype>=0.10.4
typeguard>=2.13.3
cloudpickle>=2.2.1
+8
View File
@@ -0,0 +1,8 @@
import cloudpickle
from jaxtyping import AbstractArray, Array, Shaped
def test_pickle():
cloudpickle.dumps(Shaped[Array, ""])
cloudpickle.dumps(AbstractArray)