diff --git a/mapytex/calculus/core/typing/__init__.py b/mapytex/calculus/core/typing/__init__.py index cd3eac4..1845502 100644 --- a/mapytex/calculus/core/typing/__init__.py +++ b/mapytex/calculus/core/typing/__init__.py @@ -37,6 +37,30 @@ def typing(node, left_v, right_v): raise TypingError(f"Unknown operation ({node})") return operation(left_v, right_v) +def typing_capacities(node): + """ Test an operation through all MOs + + :param operation: string which represent an (mo, mo) -> mo + :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] + lines = [[node] + [mo.__name__ for mo in MOS]] + for left_mo in MOS: + lines.append( + [left_mo.__name__] + \ + [(left_mo, i) in op.funcs for i in MOS] + ) + return lines + +typing.__doc__ += "Implemented typing operations among MOs" +for op in OPERATIONS: + typing.__doc__ += f"\n{tabulate(typing_capacities(op), tablefmt='grid')} \n" + # ----------------------------- # Reglages pour 'vim'