@@ -38,7 +38,6 @@ def __init__(self, parent=None, parent_pos=(0, 0),
3838 h_pad = None , w_pad = None , width_ratios = None ,
3939 height_ratios = None ):
4040 Variable = kiwi .Variable
41- self .parent = parent
4241 self .parent_pos = parent_pos
4342 self .parent_inner = parent_inner
4443 self .name = name + seq_id ()
@@ -57,12 +56,10 @@ def __init__(self, parent=None, parent_pos=(0, 0),
5756 if not isinstance (parent , LayoutGrid ):
5857 # parent can be a rect if not a LayoutGrid
5958 # allows specifying a rectangle to contain the layout.
60- self .parent = parent
6159 self .solver = kiwi .Solver ()
6260 else :
63- self .parent = parent
6461 parent .add_child (self , * parent_pos )
65- self .solver = self . parent .solver
62+ self .solver = parent .solver
6663 # keep track of artist associated w/ this layout. Can be none
6764 self .artists = np .empty ((nrows , ncols ), dtype = object )
6865 self .children = np .empty ((nrows , ncols ), dtype = object )
@@ -77,14 +74,8 @@ def __init__(self, parent=None, parent_pos=(0, 0),
7774
7875 sol = self .solver
7976
80- # These are redundant, but make life easier if
81- # we define them all. All that is really
82- # needed is left/right, margin['left'], and margin['right']
83- self .widths = [Variable (f'{ sn } widths[{ i } ]' ) for i in range (ncols )]
8477 self .lefts = [Variable (f'{ sn } lefts[{ i } ]' ) for i in range (ncols )]
8578 self .rights = [Variable (f'{ sn } rights[{ i } ]' ) for i in range (ncols )]
86- self .inner_widths = [Variable (f'{ sn } inner_widths[{ i } ]' )
87- for i in range (ncols )]
8879 for todo in ['left' , 'right' , 'leftcb' , 'rightcb' ]:
8980 self .margins [todo ] = [Variable (f'{ sn } margins[{ todo } ][{ i } ]' )
9081 for i in range (ncols )]
@@ -95,9 +86,6 @@ def __init__(self, parent=None, parent_pos=(0, 0),
9586 self .margins [todo ] = np .empty ((nrows ), dtype = object )
9687 self .margin_vals [todo ] = np .zeros (nrows )
9788
98- self .heights = [Variable (f'{ sn } heights[{ i } ]' ) for i in range (nrows )]
99- self .inner_heights = [Variable (f'{ sn } inner_heights[{ i } ]' )
100- for i in range (nrows )]
10189 self .bottoms = [Variable (f'{ sn } bottoms[{ i } ]' ) for i in range (nrows )]
10290 self .tops = [Variable (f'{ sn } tops[{ i } ]' ) for i in range (nrows )]
10391 for todo in ['bottom' , 'top' , 'bottomcb' , 'topcb' ]:
@@ -109,7 +97,7 @@ def __init__(self, parent=None, parent_pos=(0, 0),
10997 # set these margins to zero by default. They will be edited as
11098 # children are filled.
11199 self .reset_margins ()
112- self .add_constraints ()
100+ self .add_constraints (parent )
113101
114102 self .h_pad = h_pad
115103 self .w_pad = w_pad
@@ -119,14 +107,14 @@ def __repr__(self):
119107 for i in range (self .nrows ):
120108 for j in range (self .ncols ):
121109 str += f'{ i } , { j } : ' \
122- f'L( { self .lefts [j ].value ():1.3f} , ' \
110+ f'L{ self .lefts [j ].value ():1.3f} , ' \
123111 f'B{ self .bottoms [i ].value ():1.3f} , ' \
124- f'W{ self .widths [j ].value ():1.3f} , ' \
125- f'H{ self .heights [i ].value ():1.3f} , ' \
126- f'innerW{ self .inner_widths [j ].value ():1.3f} , ' \
127- f'innerH{ self .inner_heights [i ].value ():1.3f} , ' \
112+ f'R{ self .rights [j ].value ():1.3f} , ' \
113+ f'T{ self .tops [i ].value ():1.3f} , ' \
128114 f'ML{ self .margins ["left" ][j ].value ():1.3f} , ' \
129- f'MR{ self .margins ["right" ][j ].value ():1.3f} , \n '
115+ f'MR{ self .margins ["right" ][j ].value ():1.3f} , ' \
116+ f'MB{ self .margins ["bottom" ][i ].value ():1.3f} , ' \
117+ f'MT{ self .margins ["top" ][i ].value ():1.3f} , \n '
130118 return str
131119
132120 def reset_margins (self ):
@@ -139,11 +127,11 @@ def reset_margins(self):
139127 'leftcb' , 'rightcb' , 'bottomcb' , 'topcb' ]:
140128 self .edit_margins (todo , 0.0 )
141129
142- def add_constraints (self ):
130+ def add_constraints (self , parent ):
143131 # define self-consistent constraints
144132 self .hard_constraints ()
145133 # define relationship with parent layoutgrid:
146- self .parent_constraints ()
134+ self .parent_constraints (parent )
147135 # define relative widths of the grid cells to each other
148136 # and stack horizontally and vertically.
149137 self .grid_constraints ()
@@ -177,12 +165,11 @@ def add_child(self, child, i=0, j=0):
177165 # np.ix_ returns the cross product of i and j indices
178166 self .children [np .ix_ (np .atleast_1d (i ), np .atleast_1d (j ))] = child
179167
180- def parent_constraints (self ):
168+ def parent_constraints (self , parent ):
181169 # constraints that are due to the parent...
182170 # i.e. the first column's left is equal to the
183171 # parent's left, the last column right equal to the
184172 # parent's right...
185- parent = self .parent
186173 if not isinstance (parent , LayoutGrid ):
187174 # specify a rectangle in figure coordinates
188175 hc = [self .lefts [0 ] == parent [0 ],
0 commit comments