original_docstring: 
      Create a spiral inside a polygon by offsetting the
      polygon by a step distance and then interpolating.
  
      Parameters
      -----------
      polygon : shapely.geometry.Polygon object
          Source geometry to create spiral inside of
      step : float
          Distance between each step of the curve
  
      Returns
      ----------
      spiral : (n, 2) float
          Points representing a spiral path
          contained inside polygon
      
docstring: Create a spiral inside a polygon by offsetting the
  polygon by a step distance and then interpolating.
  
  Parameters
  
  polygon : shapely.geometry.Polygon object
  Source geometry to create spiral inside of
  step : float
  Distance between each step of the curve
  
  Returns
  
  spiral : (n, 2) float
  Points representing a spiral path
  contained inside polygon
docstring_tokens: Create a spiral inside a polygon by offsetting the polygon by a step distance and then interpolating . Parameters polygon : shapely . geometry . Polygon object Source geometry to create spiral inside of step : float Distance between each step of the curve Returns spiral : ( n 2 ) float Points representing a spiral path contained inside polygon
code: def offset(polygon, step):
      """
      Create a spiral inside a polygon by offsetting the
      polygon by a step distance and then interpolating.
  
      Parameters
      -----------
      polygon : shapely.geometry.Polygon object
          Source geometry to create spiral inside of
      step : float
          Distance between each step of the curve
  
      Returns
      ----------
      spiral : (n, 2) float
          Points representing a spiral path
          contained inside polygon
      """
      g, offset = polygons.offset_graph(polygon, step)
  
      # make sure offset polygon graph topology supports this
      assert graph.is_1D_graph(g)
  
      # make sure polygons don't have interiors
      assert all(len(v.interiors) == 0 for v in offset.values())
  
      # starting point for each section of curve
      start = None
      # store a sequence of (m,2) float point curves
      path = []
  
      # root node is index 0
      nodes = list(nx.topological_sort(g))
      # loop through nodes in topological order
      for i in range(len(nodes) - 1):
          # get the polygons we're looking at
          a = offset[nodes[i]]
          b = offset[nodes[i + 1]]
          # create the spiral section between a and b
          curve = polygons.interpolate(a, b, start=start)
          # make sure the next section starts where this
          # section of the curve ends
          start = curve[-1]
          # store the curve in the main sequence
          path.append(curve)
  
      # stack to a single (n,2) float list of points
      path = np.vstack(path)
  
      # check to make sure we didn't jump on any step
      # that would indicate we did something super screwey
      gaps = (np.diff(path, axis=0) ** 2).sum(axis=1).max()
      assert gaps < 1e-3
  
      return path
code_tokens: def offset ( polygon , step ) : g , offset = polygons . offset_graph ( polygon , step ) assert graph . is_1D_graph ( g ) assert all ( len ( v . interiors ) == 0 for v in offset . values ( ) ) start = None path = [ ] nodes = list ( nx . topological_sort ( g ) ) for i in range ( len ( nodes ) - 1 ) : a = offset [ nodes [ i ] ] b = offset [ nodes [ i + 1 ] ] curve = polygons . interpolate ( a , b , start = start ) start = curve [ - 1 ] path . append ( curve ) path = np . vstack ( path ) gaps = ( np . diff ( path , axis = 0 ) ** 2 ) . sum ( axis = 1 ) . max ( ) assert gaps < 1e-3 return path
short_docstring: Create a spiral inside a polygon by offsetting the
  polygon by a step distance and then interpolating.
short_docstring_tokens: Create a spiral inside a polygon by offsetting the polygon by a step distance and then interpolating .
comment: """
      Create a spiral inside a polygon by offsetting the
      polygon by a step distance and then interpolating.
  
      Parameters
      -----------
      polygon : shapely.geometry.Polygon object
          Source geometry to create spiral inside of
      step : float
          Distance between each step of the curve
  
      Returns
      ----------
      spiral : (n, 2) float
          Points representing a spiral path
          contained inside polygon
      """$SEP$# make sure offset polygon graph topology supports this$SEP$# make sure polygons don't have interiors$SEP$# starting point for each section of curve$SEP$# store a sequence of (m,2) float point curves$SEP$# root node is index 0$SEP$# loop through nodes in topological order$SEP$# get the polygons we're looking at$SEP$# create the spiral section between a and b$SEP$# make sure the next section starts where this$SEP$# section of the curve ends$SEP$# store the curve in the main sequence$SEP$# stack to a single (n,2) float list of points$SEP$# check to make sure we didn't jump on any step$SEP$# that would indicate we did something super screwey