code: def test_overlay_nybb(how, nybb_filename):
      polydf = read_file(nybb_filename)
  
      # The circles have been constructed and saved at the time the expected
      # results were created (exact output of buffer algorithm can slightly
      # change over time -> use saved ones)
      # # construct circles dataframe
      # N = 10
      # b = [int(x) for x in polydf.total_bounds]
      # polydf2 = GeoDataFrame(
      #     [
      #         {"geometry": Point(x, y).buffer(10000), "value1": x + y, "value2": x - y}
      #         for x, y in zip(
      #             range(b[0], b[2], int((b[2] - b[0]) / N)),
      #             range(b[1], b[3], int((b[3] - b[1]) / N)),
      #         )
      #     ],
      #     crs=polydf.crs,
      # )
      polydf2 = read_file(
          os.path.join(DATA, "nybb_qgis", "polydf2.shp")
      )
  
      result = overlay(polydf, polydf2, how=how)
  
      cols = [
          "BoroCode",
          "BoroName",
          "Shape_Leng",
          "Shape_Area",
          "value1",
          "value2",
      ]
      if how == "difference":
          cols = cols[:-2]
  
      # expected result
  
      if how == "identity":
          # read union one, further down below we take the appropriate subset
          expected = read_file(
              os.path.join(DATA, "nybb_qgis", "qgis-union.shp")
          )
      else:
          expected = read_file(
              os.path.join(
                  DATA, "nybb_qgis", "qgis-{0}.shp".format(how)
              )
          )
  
      # The result of QGIS for 'union' contains incorrect geometries:
      # 24 is a full original circle overlapping with unioned geometries, and
      # 27 is a completely duplicated row)
      if how == "union":
          expected = expected.drop([24, 27])
          expected.reset_index(inplace=True, drop=True)
      # Eliminate observations without geometries (issue from QGIS)
      expected = expected[expected.is_valid]
      expected.reset_index(inplace=True, drop=True)
  
      if how == "identity":
          expected = expected[expected.BoroCode.notnull()].copy()
  
      # Order GeoDataFrames
      expected = expected.sort_values(cols).reset_index(drop=True)
  
      # TODO needed adaptations to result
      result = result.sort_values(cols).reset_index(drop=True)
  
      if how in ("union", "identity"):
          # concat < 0.23 sorts, so changes the order of the columns
          # but at least we ensure 'geometry' is the last column
          assert result.columns[-1] == "geometry"
          assert len(result.columns) == len(expected.columns)
          result = result.reindex(columns=expected.columns)
  
      # the ordering of the spatial index results causes slight deviations
      # in the resultant geometries for multipolygons
      # for more details on the discussion, see:
      # https://github.com/geopandas/geopandas/pull/1338
      # https://github.com/geopandas/geopandas/issues/1337
  
      # Temporary workaround below:
  
      # simplify multipolygon geometry comparison
      # since the order of the constituent polygons depends on
      # the ordering of spatial indexing results, we cannot
      # compare symmetric_difference results directly when the
      # resultant geometry is a multipolygon
  
      # first, check that all bounds and areas are approx equal
      # this is a very rough check for multipolygon equality
      kwargs = {}
      pd.testing.assert_series_equal(
          result.geometry.area, expected.geometry.area, **kwargs
      )
      pd.testing.assert_frame_equal(
          result.geometry.bounds, expected.geometry.bounds, **kwargs
      )
  
      # There are two cases where the multipolygon have a different number
      # of sub-geometries -> not solved by normalize (and thus drop for now)
      if how == "symmetric_difference":
          expected.loc[9, "geometry"] = None
          result.loc[9, "geometry"] = None
  
      if how == "union":
          expected.loc[24, "geometry"] = None
          result.loc[24, "geometry"] = None
  
      assert_geodataframe_equal(
          result,
          expected,
          normalize=True,
          check_crs=False,
          check_column_type=False,
          check_less_precise=True,
      )
  
imports: import os
  import numpy
  import pandas
  from shapely import make_valid
  from shapely.geometry import Point, Polygon, LineString, GeometryCollection, box
  import geopandas
  from geopandas import GeoDataFrame, GeoSeries, overlay, read_file
  from geopandas._compat import PANDAS_GE_20
  from geopandas.testing import assert_geodataframe_equal, assert_geoseries_equal
  import pytest
label_desc: Use image node_id 6 for calling a global function with example usage: test_overlay_nybb(how, nybb_filename) without return types