def reaction_signature(eq, direction=False, stoichiometry=False):
def compounds_sig(compounds):<EOL><INDENT>if stoichiometry:<EOL><INDENT>return tuple(sorted(compounds))<EOL><DEDENT>else:<EOL><INDENT>return tuple(sorted(compound for compound, _ in compounds))<EOL><DEDENT><DEDENT>left = compounds_sig(eq.left)<EOL>right = compounds_sig(eq.right)<EOL>if left < right:<EOL><INDENT>reaction_sig = left, right<EOL>direction_sig = eq.direction<EOL><DEDENT>else:<EOL><INDENT>reaction_sig = right, left<EOL>direction_sig = eq.direction.flipped()<EOL><DEDENT>if direction:<EOL><INDENT>return reaction_sig, direction_sig<EOL><DEDENT>return reaction_sig<EOL>
Return unique signature object for :class:`Reaction`.

    Signature objects are hashable, and compare equal only if the reactions
    are considered the same according to the specified rules.

    Args:
        direction: Include reaction directionality when considering equality.
        stoichiometry: Include stoichiometry when considering equality.