Bases: object
A graph representing the paths between coordinate frames.
Attributes Summary
frame_set | A set of all the frame classes present in this TransformGraph. |
Methods Summary
add_transform(fromsys, tosys, transform) | Add a new coordinate transformation to the graph. |
find_shortest_path(fromsys, tosys) | Computes the shortest distance along the transform graph from one system to another. |
get_names() | Returns all available transform names. |
get_transform(fromsys, tosys) | Generates and returns the CompositeTransform for a transformation between two coordinate systems. |
invalidate_cache() | Invalidates the cache that stores optimizations for traversing the transform graph. |
lookup_name(name) | Tries to locate the coordinate class with the provided alias. |
remove_transform(fromsys, tosys, transform) | Removes a coordinate transform from the graph. |
to_dot_graph([priorities, addnodes, savefn, ...]) | Converts this transform graph to the graphviz DOT format. |
to_networkx_graph() | Converts this transform graph into a networkx graph. |
transform(transcls, fromsys, tosys[, priority]) | A function decorator for defining transformations. |
Attributes Documentation
A set of all the frame classes present in this TransformGraph.
Methods Documentation
Add a new coordinate transformation to the graph.
Parameters: | fromsys : class
tosys : class
transform : CoordinateTransform or similar callable
|
---|---|
Raises: | TypeError
|
Computes the shortest distance along the transform graph from one system to another.
Parameters: | fromsys : class
tosys : class
|
---|---|
Returns: | path : list of classes or None
distance : number
|
Returns all available transform names. They will all be valid arguments to lookup_name.
Returns: | nms : list
|
---|
Generates and returns the CompositeTransform for a transformation between two coordinate systems.
Parameters: | fromsys : class
tosys : class
|
---|---|
Returns: | trans : CompositeTransform or None
|
Notes
This function always returns a CompositeTransform, because CompositeTransform is slightly more adaptable in the way it can be called than other transform classes. Specifically, it takes care of inetermediate steps of transformations in a way that is consistent with 1-hop transformations.
Invalidates the cache that stores optimizations for traversing the transform graph. This is called automatically when transforms are added or removed, but will need to be called manually if weights on transforms are modified inplace.
Tries to locate the coordinate class with the provided alias.
Parameters: | name : str
|
---|---|
Returns: | coordcls
|
Removes a coordinate transform from the graph.
Parameters: | fromsys : class or None tosys : class or None transform : callable or None |
---|
Converts this transform graph to the graphviz DOT format.
Optionally saves it (requires graphviz be installed and on your path).
Parameters: | priorities : bool
addnodes : sequence of str
savefn : None or str
savelayout : str saveformat : str
|
---|---|
Returns: | dotgraph : str
|
Converts this transform graph into a networkx graph.
Note
You must have the networkx package installed for this to work.
Returns: | nxgraph : networkx.Graph
|
---|
A function decorator for defining transformations.
Note
If decorating a static method of a class, @staticmethod should be added above this decorator.
Parameters: | transcls : class
fromsys : class
tosys : class
priority : number
|
---|---|
Returns: | deco : function
|
Notes
This decorator assumes the first argument of the transcls initializer accepts a callable, and that the second and third are fromsys and tosys. If this is not true, you should just initialize the class manually and use add_transform instead of using this decorator.
Examples
graph = TransformGraph()
class Frame1(BaseCoordinateFrame):
...
class Frame2(BaseCoordinateFrame):
...
@graph.transform(FunctionTransform, Frame1, Frame2)
def f1_to_f2(f1_obj):
... do something with f1_obj ...
return f2_obj