00001 __author__ = "Sean Ross-Ross"
00002 __version__ = "Simple example v(3.2)"
00003
00004 """
00005 simple example of how to create a vector and run
00006 commands
00007 """
00008 from slimpy_base import Space, Execute
00009
00010 from slimpy_base.setup import *
00011
00012 from slimpy_base.utils.slim_decorators import depends_on
00013
00014
00015
00016
00017 defaults = { 'thr':0.1 }
00018
00019
00020 @depends_on('thr')
00021 def Simple_bldr( target, source, env ):
00022 'create a 10 by 10 image of zeros and add 3 to it'
00023
00024
00025 env = parse_env( env ,defaults)
00026
00027 thr = env['thr']
00028
00029
00030 space = Space( n1=10, n2=10, data_type='float', plugin='slim2rsf' )
00031
00032 vector1 = space.zeros()
00033
00034
00035 vec2 = vector1.thr(thr) * 3
00036
00037
00038 vec2.setName( target[0] )
00039
00040
00041 Execute()
00042
00043
00044 if __name__ == '__main__':
00045
00046 Parameters( 'target', 'thr' )
00047 Defaults( defaults )
00048 Types( thr=float )
00049
00050
00051
00052 check_required( 'target' )
00053
00054 env = parse_args( )
00055
00056
00057 target = [env.pop( 'target' )]
00058
00059 Simple_bldr( target, None, defaults )
00060
00061 else:
00062
00063 __all__ = ['Simple']
00064
00065
00066 from slimproj_core.builders.CreateBuilders import add_to_slim_env
00067
00068 Simple = add_to_slim_env("Simple", Simple_bldr )
00069