Skip to content

Commit 49b2a86

Browse files
committed
TL: conveniency changes on utilities
1 parent 371d284 commit 49b2a86

4 files changed

Lines changed: 5 additions & 5 deletions

File tree

qmat/qcoeff/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def register(cls: type[T]) -> type[T]:
216216
"""Class decorator to register a specialized :class:`QGenerator` class in qmat"""
217217
# Check for correct overriding
218218
for name in ["nodes", "Q", "weights", "order"]:
219-
checkOverriding(cls, name)
219+
checkOverriding(cls, name, isProperty=True)
220220
# Check that TEST_PARAMS are given and valid if no default constructor
221221
try:
222222
cls()

qmat/qdelta/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def genCoeffs(self, k=None, form="Z2N", dTau=False):
217217
def register(cls: type[T]) -> type[T]:
218218
"""Class decorator to register a specialized :class:`QDeltaGenerator` class in `qmat`"""
219219
checkGenericConstr(cls)
220-
checkOverriding(cls, "computeQDelta", isProperty=False)
220+
checkOverriding(cls, "computeQDelta")
221221
try:
222222
sig = inspect.signature(cls.computeQDelta)
223223
par = sig.parameters["k"]

qmat/solvers/generic/diffops.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
def registerDiffOp(cls: type[T]) -> type[T]:
2020
"""Class decorator to register a specialized :class:`DiffOp` class in `qmat`"""
21-
checkOverriding(cls, "evalF", isProperty=False)
21+
checkOverriding(cls, "evalF")
2222
storeClass(cls, DIFFOPS)
2323
return cls
2424

qmat/utils/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
from time import time
1515

1616

17-
def checkOverriding(cls, name, isProperty=True):
17+
def checkOverriding(cls, name, isProperty=False, mroIndex=-2):
1818
"""Check if a class overrides a method with a given name"""
1919
method = getattr(cls, name)
20-
parent = getattr(cls.mro()[-2], name)
20+
parent = getattr(cls.mro()[mroIndex], name)
2121
assert method != parent, \
2222
f"{name} method must be overriden in {cls.__name__} class"
2323
if isProperty:

0 commit comments

Comments
 (0)