Python prevents instantiation of abstract base classes, but only if they have abstract methods. Thus, for example, the following works:
>>> QuantumSymbol('a', hs=1)
despite QuantumSymbol being an abstract class:
class QuantumSymbol(QuantumExpression, metaclass=ABCMeta)
This can cause problems, as abstract classes may not define all the necessary class attributes for algebraic operations to work (and there's no way in Python to declare abstract class attributes, which Python could catch similar to abstract methods)
We should figure out some general way in Expression.__init__ to raise an exception if any class whose type is a direct subclass of ABCMeta is being instantiated. So far, I haven't found a way to perform this check.
Python prevents instantiation of abstract base classes, but only if they have abstract methods. Thus, for example, the following works:
despite
QuantumSymbolbeing an abstract class:This can cause problems, as abstract classes may not define all the necessary class attributes for algebraic operations to work (and there's no way in Python to declare abstract class attributes, which Python could catch similar to abstract methods)
We should figure out some general way in
Expression.__init__to raise an exception if any class whose type is a direct subclass ofABCMetais being instantiated. So far, I haven't found a way to perform this check.