<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import , division , print_function <EOL> import numpy as np <EOL> from numpy . random import random as r <EOL> from . . import Data , DataCollection <EOL> from . . link_helpers import LinkSame <EOL> def test_1d_world_link ( ) : <EOL> x , y = r ( <NUM_LIT:10> ) , r ( <NUM_LIT:10> ) <EOL> d1 = Data ( label = '<STR_LIT>' , x = x ) <EOL> d2 = Data ( label = '<STR_LIT>' , y = y ) <EOL> dc = DataCollection ( [ d1 , d2 ] ) <EOL> dc . add_link ( LinkSame ( d2 . get_world_component_id ( <NUM_LIT:0> ) , d1 . id [ '<STR_LIT:x>' ] ) ) <EOL> assert d2 . get_world_component_id ( <NUM_LIT:0> ) in d1 . components <EOL> np . testing . assert_array_equal ( d1 [ d2 . get_world_component_id ( <NUM_LIT:0> ) ] , x ) <EOL> np . testing . assert_array_equal ( d1 [ d2 . get_pixel_component_id ( <NUM_LIT:0> ) ] , x ) <EOL> def test_3d_world_link ( ) : <EOL> """<STR_LIT>""" <EOL> x , y , z = r ( <NUM_LIT:10> ) , r ( <NUM_LIT:10> ) , r ( <NUM_LIT:10> ) <EOL> cat = Data ( label = '<STR_LIT>' , x = x , y = y , z = z ) <EOL> im = Data ( label = '<STR_LIT>' , inten = r ( ( <NUM_LIT:3> , <NUM_LIT:3> , <NUM_LIT:3> ) ) ) <EOL> dc = DataCollection ( [ cat , im ] ) <EOL> dc . add_link ( LinkSame ( im . get_world_component_id ( <NUM_LIT:2> ) , cat . id [ '<STR_LIT:x>' ] ) ) <EOL> dc . add_link ( LinkSame ( im . get_world_component_id ( <NUM_LIT:1> ) , cat . id [ '<STR_LIT:y>' ] ) ) <EOL> dc . add_link ( LinkSame ( im . get_world_component_id ( <NUM_LIT:0> ) , cat . id [ '<STR_LIT:z>' ] ) ) <EOL> np . testing . assert_array_equal ( cat [ im . get_pixel_component_id ( <NUM_LIT:2> ) ] , x ) <EOL> np . testing . assert_array_equal ( cat [ im . get_pixel_component_id ( <NUM_LIT:1> ) ] , y ) <EOL> np . testing . assert_array_equal ( cat [ im . get_pixel_component_id ( <NUM_LIT:0> ) ] , z ) <EOL> def test_2d_world_link ( ) : <EOL> """<STR_LIT>""" <EOL> x , y = r ( <NUM_LIT:10> ) , r ( <NUM_LIT:10> ) <EOL> cat = Data ( label = '<STR_LIT>' , x = x , y = y ) <EOL> im = Data ( label = '<STR_LIT>' , inten = r ( ( <NUM_LIT:3> , <NUM_LIT:3> ) ) ) <EOL> dc = DataCollection ( [ cat , im ] ) <EOL> dc . add_link ( LinkSame ( im . get_world_component_id ( <NUM_LIT:0> ) , cat . id [ '<STR_LIT:x>' ] ) ) <EOL> dc . add_link ( LinkSame ( im . get_world_component_id ( <NUM_LIT:1> ) , cat . id [ '<STR_LIT:y>' ] ) ) <EOL> np . testing . assert_array_equal ( cat [ im . get_pixel_component_id ( <NUM_LIT:0> ) ] , x ) <EOL> np . testing . assert_array_equal ( cat [ im . get_pixel_component_id ( <NUM_LIT:1> ) ] , y ) </s>
