Closed goerz closed 7 years ago
Calling the substitute method on any Singleton object should always return the same object. E.g. for the IdentityOperator (II), we would like
substitute
IdentityOperator
II
assert II.substitute({}) is II
However, since II._class is not II, the call to substitute fails:
II._class is not II
self = IdentityOperator, var_map = {} def _substitute(self, var_map): if self in var_map: return var_map[self] #if isinstance(self.__class__, Singleton): #return self new_args = [substitute(arg, var_map) for arg in self.args] new_kwargs = {key: substitute(val, var_map) for (key, val) in self.kwargs.items()} > return self.__class__.create(*new_args, **new_kwargs) E TypeError: create() missing 1 required positional argument: 'self' qnet/algebra/abstract_algebra.py:280: TypeError
Calling the
substitute
method on any Singleton object should always return the same object. E.g. for theIdentityOperator
(II
), we would likeHowever, since
II._class is not II
, the call tosubstitute
fails: