definition_helpers module
Full Documentation for hippynn.graphs.nodes.base.definition_helpers
module.
Click here for a summary page.
Tools for organizing node definitions.
Usage of these tools is optional; they support node definitions but are not required.
Note
The functions in this module are intended purely for defining new types of nodes. They are not strictly necessary; they only aid in defining more complex node behavior in a simple fashion.
- class CompatibleIdxTypeTransformer(form)[source]
Bases:
FormTransformer
- class FormAssertLength(length)[source]
Bases:
FormAssertion
- class FormAssertion(form)[source]
Bases:
FormHandler
- class FormTransformer(form, fn)[source]
Bases:
FormHandler
- class IndexFormTransformer(form, idxstates)[source]
Bases:
FormTransformer
- class MainOutputTransformer(form)[source]
Bases:
FormTransformer
- class ParentExpander[source]
Bases:
object
Manager object to register and implement optional steps in building a graph node.
- assertlen(length)[source]
Assert that there are a given number of parents.
- Parameters:
length
- Returns:
Note
It is recommended only to use this function once as the final stage of expanding a node’s parents, to ensure that a node can be constructed directly from a satisfactory set of parents that doesn’t require any expansion.
- matched_idx_coercion(form, needed_index_states)[source]
Apply coercion to the needed index states if the given form is present. :param form: :param needed_index_states: :return:
- matchlen(length)[source]
Decorator: The decorated function will be applied if the number of parents matches the given length. :param length: :return:
- require_compatible_idx_states()[source]
Ensure that all parents have commensurate index states. :return:
- require_idx_states(*needed_index_states)[source]
Always coerce the nodes into a needed index state.
- Parameters:
needed_index_states
- Returns:
Note
It is recommended only to use this function once as the final stage of expanding a node’s parents, to ensure that a node can be constructed directly from a satisfactory set of parents that doesn’t require any expansion.
- temporary_parents(child, parents)[source]
Context manager for temporarily connecting a node to a set of parents. This is used during parent expansion so that find_relatives and find_unique_relatives can treat the nodes as connected even though they are not fully formed.
- Parameters:
child
parents
- Returns:
None