LinkHelperRegistry

class glue.config.LinkHelperRegistry[source]

Bases: glue.config.Registry

Stores helper objects that compute many ComponentLinks at once

Link helpers can either be functions or subclasses of ~glue.core.link_helpers.LinkCollection. If a function, it should take a list of ~glue.core.component_id.ComponentIDs as inputs, and returns an iterable of ~glue.core.component_link.ComponentLink objects.

A link helper should only link components between two datasets, and the order of the inputs to the function should be the ~glue.core.component_id.ComponentIDs of the first dataset, followed by the ones for the second dataset. Human-readable names for the input and output components should be given using input_labels and output_labels

New link helpers can be registered with e.g.:

@link_helper('Links degrees and arcseconds in both directions',
             input_labels=['degree'], output_labels=['arcsecond'])
def new_helper(degree, arcsecond):
    return [ComponentLink([degree], arcsecond, using=lambda d: d*3600),
            ComponentLink([arcsecond], degree, using=lambda a: a/3600)]

Methods Summary

__call__([info, input_labels, ...])

This is provided so that registry instances can be used as decorators.

Methods Documentation

__call__(info=None, input_labels=None, output_labels=None, category='General')[source]

This is provided so that registry instances can be used as decorators. The decorators should add the decorated code object to the registry, and return the original function