You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
In the abstract class, set class attributes that subclasses must overwrites to AbstractClassAttributes
In QnetABCMeta, check that no class attributes are AbstractClassAttributes, otherwise raise a TypeError: Can't instantiate abstract class with abstract class attribute
QnetABCMeta might also implement some mechanism to categorically forbid instantiating classes that directly have the QnetABCMeta class, but this would be in addition to providing abstract class attributes.
Python prevents instantiation of abstract base classes, but only if they have abstract methods. Thus, for example, the following works:
despite
QuantumSymbol
being 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 ofABCMeta
is being instantiated. So far, I haven't found a way to perform this check.The text was updated successfully, but these errors were encountered: