diff --git a/doc/reference.rst b/doc/reference.rst index 03545579f45f52343cd716851cf58b6489579bd8..9038b15368267e1bc13c1ab87ef747e8bf1d3126 100644 --- a/doc/reference.rst +++ b/doc/reference.rst @@ -82,6 +82,16 @@ Error Reporting .. exception:: Error +Global Data +^^^^^^^^^^^ + +.. data:: DEFAULT_CONTEXT + + ISL objects being unpickled or initialized from strings will be instatiated + within this :class:`Context`. + + .. versionadded:: 2015.2 + Symbolic Constants ^^^^^^^^^^^^^^^^^^ diff --git a/islpy/__init__.py b/islpy/__init__.py index fd006bc9bc73ac60a40338e7a8dbed618c1cc7a2..7b3c8ce5ac73c71e827d93ce7603e7c2285f4369 100644 --- a/islpy/__init__.py +++ b/islpy/__init__.py @@ -139,14 +139,14 @@ def _add_functionality(): new_ctx._release() def context_getstate(self): - if self.data == _DEFAULT_CONTEXT.data: + if self.data == DEFAULT_CONTEXT.data: return ("default",) else: return (None,) def context_setstate(self, data): if data[0] == "default": - self._setup(_DEFAULT_CONTEXT.data) + self._setup(DEFAULT_CONTEXT.data) else: context_init(self) @@ -175,7 +175,7 @@ def _add_functionality(): raise TypeError("'s' argument not supplied") if context is None: - context = _DEFAULT_CONTEXT + context = DEFAULT_CONTEXT new_me = self.read_from_str(context, s) self._setup(new_me._release()) @@ -232,10 +232,16 @@ def _add_functionality(): # {{{ rich comparisons def obj_eq(self, other): + assert self.get_ctx() == other.get_ctx(), ( + "Equality-comparing two objects from different ISL Contexts " + "will likely lead to entertaining (but never useful) results. " + "In particular, Spaces with matching names will no longer be " + "equal.") + return self.is_equal(other) def obj_ne(self, other): - return not self.is_equal(other) + return not self.__eq__(other) for cls in ALL_CLASSES: if hasattr(cls, "is_equal"): @@ -488,7 +494,7 @@ def _add_functionality(): raise TypeError("'name' argument not supplied") if context is None: - context = _DEFAULT_CONTEXT + context = DEFAULT_CONTEXT new_me = cls.alloc(context, name, user) self._setup(new_me._release()) @@ -775,7 +781,7 @@ def _add_functionality(): raise TypeError("'src' argument not supplied") if context is None: - context = _DEFAULT_CONTEXT + context = DEFAULT_CONTEXT if isinstance(src, six.string_types): new_me = Val.read_from_str(context, src) @@ -1012,7 +1018,7 @@ def _add_functionality(): _add_functionality() -_DEFAULT_CONTEXT = Context() +DEFAULT_CONTEXT = Context() def _back_to_basic(new_obj, old_obj):