A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://glue-core.readthedocs.io/en/latest/api/glue.core.component_link.ComponentLink.html below:

ComponentLink — Glue documentation

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

Methods Summary

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]#

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4