original_docstring: A generator function that returns frames of converting a polygon
          to a square
  
          NOTE: the shape that is actively being worked on should be the last
          Shape in the frame
          
docstring: A generator function that returns frames of converting a polygon
  to a square
  
  the shape that is actively being worked on should be the last
  Shape in the frame
docstring_tokens: A generator function that returns frames of converting a polygon to a square the shape that is actively being worked on should be the last Shape in the frame
code: def _squarify(self):
          """"A generator function that returns frames of converting a polygon
          to a square
  
          NOTE: the shape that is actively being worked on should be the last
          Shape in the frame
          """
          last = self._polygon2triangles()
          yield last[:]
          new_last = list()
          # Turn all triangles to right-angled triangles
          while len(last) > 0:
              t = last.pop()
              new_last.extend(t.to_rightangle())
              yield last + new_last
  
          # Turn all right-angled triangles to rectangles
          last, new_last = new_last, list()
          while len(last) > 0:
              t = last.pop()
              new_last.append(None)
              for t in triangle2rectangle(t):
                  a = new_last.pop()
                  new_last.append(t)
                  yield last + new_last
  
          # Turn all rectangles to squares
          last, new_last = new_last, list()
          while len(last) > 0:
              s = last.pop()
              new_last.append(None)
              for r in rectangle2square(s):
                  new_last.pop()
                  new_last.append(r)
                  yield last + new_last
  
          # Merge all squares
          last, new_last = new_last, list()
          while len(last) > 1:
              r, s = last.pop(), last.pop()
              last.append(None)
              for s in merge_squares(s, r):
                  last.pop()
                  last.append(s)
                  yield last[:]
              q = last.pop()
              q = q.translate((0, q.height().length()))
              last.append(q)
              yield last
code_tokens: def _squarify ( self ) : last = self . _polygon2triangles ( ) yield last [ : ] new_last = list ( ) while len ( last ) > 0 : t = last . pop ( ) new_last . extend ( t . to_rightangle ( ) ) yield last + new_last last , new_last = new_last , list ( ) while len ( last ) > 0 : t = last . pop ( ) new_last . append ( None ) for t in triangle2rectangle ( t ) : a = new_last . pop ( ) new_last . append ( t ) yield last + new_last last , new_last = new_last , list ( ) while len ( last ) > 0 : s = last . pop ( ) new_last . append ( None ) for r in rectangle2square ( s ) : new_last . pop ( ) new_last . append ( r ) yield last + new_last last , new_last = new_last , list ( ) while len ( last ) > 1 : r , s = last . pop ( ) , last . pop ( ) last . append ( None ) for s in merge_squares ( s , r ) : last . pop ( ) last . append ( s ) yield last [ : ] q = last . pop ( ) q = q . translate ( ( 0 , q . height ( ) . length ( ) ) ) last . append ( q ) yield last
short_docstring: A generator function that returns frames of converting a polygon
  to a square
short_docstring_tokens: A generator function that returns frames of converting a polygon to a square
comment: """"A generator function that returns frames of converting a polygon
          to a square
  
          NOTE: the shape that is actively being worked on should be the last
          Shape in the frame
          """$SEP$# Turn all triangles to right-angled triangles$SEP$# Turn all right-angled triangles to rectangles$SEP$# Turn all rectangles to squares$SEP$# Merge all squares