% to be run before run_test.sli

%  Setup:
%  - 5x5 -> 5x5, extent 1. x 1. : 
%    This case has elements on boundary, thus actually several nodes in same location
%  - nodes "freely placed" at regular grid locations
%  - rectangular mask ll: [0.,0.] ur: [0.6,0.3]
%  - anchor [0,0]
%  - periodic BC
%  - This test will FAIL with an error message about nodes on the perimeter

%    Sources                      Targets
%     2  7 12 17 22    	          28 33 38 43 48
%     3  8 13 18 23		  29 34	39 44 49
%     4	 9 14 19 24		  30 35	40 45 50
%     5	10 15 20 25		  31 36	41 46 51
%     6	11 16 21 26		  32 37	42 47 52
%
%  Expected projections for some nodes
%
%    14 -> 39 44 49 29
%          40 45 50 30
%
%     2 -> 28 33 38
%          31 36 41
%          32 37 42
%
%    26 -> 52 32 37 42
%          33 38 43 48
%          34 39 44 49

% loop y-coords backwards so that we get same gid-pos mapping as on grid
[-0.5 0.5 0.25] Range 
{ /x Set [0.5 -0.5 -0.25] Range { x exch 2 arraystore } Map } Map 1 Flatten
/pos Set

/layer << /positions pos
          /extent [1.0 1.0]  % must be 1x1 so we get nodes on boundary
          /center [0. 0.]
          /edge_wrap true
          /elements /iaf_neuron
        >> def

/src_layer layer def
/tgt_layer layer def

/conns << /connection_type (divergent)
          /mask << /rectangular << /lower_left [0.0 0.0] /upper_right [0.6 0.3] >> 
                >>
       >> def