Feat(tools): Make 2 methods to explain capacities of compute and typing
This commit is contained in:
parent
f3f93d31a7
commit
ddab3cebad
@ -77,10 +77,14 @@ def compute_capacities(node):
|
|||||||
)
|
)
|
||||||
return lines
|
return lines
|
||||||
|
|
||||||
|
def describe_compute():
|
||||||
|
""" Explain which operation are handle by compue """
|
||||||
|
|
||||||
compute.__doc__ += "Implemented compute operations among MOs"
|
ans = "Implemented compute operations among MOs"
|
||||||
for op in OPERATIONS:
|
for op in OPERATIONS:
|
||||||
compute.__doc__ += f"\n{tabulate(compute_capacities(op), tablefmt='grid')} \n"
|
ans += "\n"
|
||||||
|
ans += tabulate(compute_capacities(op), tablefmt='grid')
|
||||||
|
return ans
|
||||||
|
|
||||||
|
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
|
@ -16,6 +16,15 @@ from .exceptions import TypingError
|
|||||||
# from .multiply import multiply
|
# from .multiply import multiply
|
||||||
from .divide import divide
|
from .divide import divide
|
||||||
|
|
||||||
|
from ..MO.mo import MOnumber, MOstr
|
||||||
|
from ..MO.fraction import MOFraction
|
||||||
|
from ..MO.monomial import MOstrPower, MOMonomial
|
||||||
|
|
||||||
|
from itertools import product
|
||||||
|
from tabulate import tabulate
|
||||||
|
|
||||||
|
MOS = [ MOnumber, MOstr, MOFraction, MOstrPower, MOMonomial ]
|
||||||
|
|
||||||
OPERATIONS = {
|
OPERATIONS = {
|
||||||
# "+": add,
|
# "+": add,
|
||||||
# "-": minus,
|
# "-": minus,
|
||||||
@ -43,10 +52,6 @@ def typing_capacities(node):
|
|||||||
:param operation: string which represent an (mo, mo) -> mo
|
:param operation: string which represent an (mo, mo) -> mo
|
||||||
:returns: { (motype, motype): True/False } when it's implemented
|
:returns: { (motype, motype): True/False } when it's implemented
|
||||||
|
|
||||||
:example:
|
|
||||||
>>> typing_capacities("+")
|
|
||||||
[['+', 'MOnumber', 'MOstr', 'MOFraction', 'MOstrPower', 'MOMonomial'], ['MOnumber', True, False, True, False, False], ['MOstr', False, False, False, False, False], ['MOFraction', True, False, True, False, False], ['MOstrPower', False, False, False, False, False], ['MOMonomial', False, False, False, False, False]]
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
op = OPERATIONS[node]
|
op = OPERATIONS[node]
|
||||||
lines = [[node] + [mo.__name__ for mo in MOS]]
|
lines = [[node] + [mo.__name__ for mo in MOS]]
|
||||||
@ -57,9 +62,15 @@ def typing_capacities(node):
|
|||||||
)
|
)
|
||||||
return lines
|
return lines
|
||||||
|
|
||||||
typing.__doc__ += "Implemented typing operations among MOs"
|
def describe_typing():
|
||||||
for op in OPERATIONS:
|
""" Explain which operations are handle by typing """
|
||||||
typing.__doc__ += f"\n{tabulate(typing_capacities(op), tablefmt='grid')} \n"
|
|
||||||
|
ans = "Implemented typing operations among MOs\n"
|
||||||
|
for op in OPERATIONS:
|
||||||
|
ans += "\n"
|
||||||
|
ans += tabulate(typing_capacities(op), tablefmt='grid')
|
||||||
|
|
||||||
|
return ans
|
||||||
|
|
||||||
|
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user