Glue Logo
latest
  • Installing and running glue
  • Getting started
  • Advanced User Interface Guide
  • Using the IPython terminal in Glue
  • Working with Data objects
  • Starting Glue from Python
  • Working with non-glue data objects
  • Visualizing Astronomical Dendrograms
  • Introduction to customizing/extending glue
  • List of available plugins
  • Configuring Glue via a startup file
  • Customizing your Glue environment
  • Distributing your own plugin package
  • Customizing the coordinate system of a data object
  • Programmatically configuring viewers
  • Writing a simple custom data viewer
  • Watching data for changes
  • Custom fitting plugins
  • Writing a custom viewer for glue
  • Writing a custom viewer for glue with Qt
  • Writing a custom viewer for glue with Qt and Matplotlib
  • Custom tools for viewers and custom toolbars
  • Defining your own data objects
  • Demo Videos
  • Frequently Asked Questions
  • Getting Help with Glue
  • Known issues and solutions
  • The selection/subset framework
  • The communication framework
  • The linking framework
  • Developer Guide
  • API
    • Core Data
      • glue.core.component Module
      • glue.core.component_id Module
      • glue.core.component_link Module
        • Classes
      • glue.core.coordinates Module
      • glue.core.data Module
      • glue.core.data_collection Module
      • glue.core.hub Module
      • glue.core.subset Module
      • glue.core.subset_group Module
      • glue.core.roi Module
      • glue.core.link_helpers Module
      • glue.core.data_factories Package
      • glue.core.fitters Module
      • glue.core.state_objects Module
      • glue.core.exceptions Module
      • glue.core.session Module
    • User Interface
    • Utilities
    • Plugins
Glue
  • »
  • API »
  • ComponentLink
  • Edit on GitHub

ComponentLink¶

class glue.core.component_link.ComponentLink(comp_from, comp_to, using=None, inverse=None, inverse_component_link=None, description=None, input_names=None, output_name=None)[source]¶

Bases: object

ComponentLinks represent transformation logic between ComponentIDs

Parameters
comp_fromlist of ComponentID

The input ComponentIDs

comp_toComponentID

The target component ID

usingfunc, optional

The translation function which maps data from comp_from to comp_to. The using function should satisfy using(data[comp_from[0]],...,data[comp_from[-1]]) = desired data. If not specifies, this defaults to an identity function.

inversefunc, optional

The inverse translation function, if exists

descriptionstr

A short description for the link. This is used e.g. in the link editor.

input_nameslist of str, optional

The names to use for the inputs to the using function. By default this is determined by inspecting the function signature. This is used e.g. in the link editor.

output_namestr, optional

The name to use for the output of the using function. This is used e.g. in the link editor.

Notes

Both inverse and using should accept and return numpy arrays.

Examples

def hours_to_minutes(hours):
    return hours * 60

d = Data(hour=[1, 2, 3])
hour = d.id['hour']
minute = ComponentID('minute')
link = ComponentLink( [hour], minute, using=hours_to_minutes)

link.compute(d)  # array([ 60, 120, 180])
d.add_component_link(link)
d['minute'] # array([ 60, 120, 180])

Attributes Summary

inverse

Methods Summary

compute(data[, view])

For a given data set, compute the component comp_to given the data associated with each comp_from and the using function

get_from_ids()

The list of input ComponentIDs

get_inverse()

The inverse transformation, or None

get_to_id()

The target ComponentID

get_to_ids()

get_using()

The transformation function

replace_ids(old, new)

Replace all references to an old ComponentID with references to new.

set_from_ids(_from)

set_to_id(to)

to_html()

Attributes Documentation

inverse[source]¶

Methods Documentation

compute(data, view=None)[source]¶

For a given data set, compute the component comp_to given the data associated with each comp_from and the using function

This raises an glue.core.exceptions.IncompatibleAttribute if the data set doesn’t have all the ComponentIDs needed for the transformation

Parameters
data~glue.core.data.Data

The data set to use.

viewslice or tuple, optional

Optional view (e.g. slice) through the data to use.

Returns
result

The data associated with comp_to component

get_from_ids()[source]¶

The list of input ComponentIDs

get_inverse()[source]¶

The inverse transformation, or None

get_to_id()[source]¶

The target ComponentID

get_to_ids()[source]¶
get_using()[source]¶

The transformation function

replace_ids(old, new)[source]¶

Replace all references to an old ComponentID with references to new.

Parameters
oldComponentID

ComponentID to replace.

newComponentID

ComponentID to replace with.

set_from_ids(_from)[source]¶
set_to_id(to)[source]¶
to_html()[source]¶
Previous Next

© Copyright 2012-2019, Chris Beaumont, Thomas Robitaille, Michelle Borkin. Revision 578369fa.

Built with Sphinx using a theme provided by Read the Docs.
Read the Docs v: latest
Versions
latest
stable
v0.8.x
v0.8.0
v0.7.2
v0.7.1
v0.7.x
v0.7.0
rtd
main
Downloads
On Read the Docs
Project Home
Builds