code: def test_grid_generator_demographic_parity(grid_size, grid_limit):
      disparity_moment = DemographicParity()
      events = [_ALL]
  
      grid = calculate_grid(grid_limit, grid_size, disparity_moment)
  
      expected_index = pd.MultiIndex.from_product(
          [["+", "-"], events, [0, 1]], names=[_SIGN, _EVENT, _GROUP_ID]
      )
      assert (expected_index == grid.index).all()
      grid_size_or_next_smaller_even_number = int(grid_size / 2) * 2
      step_size = 2 * grid_limit / grid_size_or_next_smaller_even_number
      columns = []
      for i in range(grid_size):
          column = pd.Series(0.0, index=expected_index)
          column["-", _ALL, 1] = max(grid_limit - step_size * i, 0)
          column["+", _ALL, 1] = max(-grid_limit + step_size * i, 0)
          columns.append(column)
      expected_grid = pd.concat(columns, axis=1)
      assert np.isclose(expected_grid.values, grid.values).all()
  
file_path: fairlearn/test/unit/reductions/grid_search/test_grid_generator.py
imports: from test.unit.reductions.grid_search.utilities import _quick_data
  import numpy
  import pandas
  import pytest
  from fairlearn.reductions import DemographicParity, EqualizedOdds
  from fairlearn.reductions._grid_search.grid_search import _GridGenerator
  from fairlearn.reductions._moments.utility_parity import _ALL, _EVENT, _GROUP_ID, _SIGN
label_desc: Use image node_id 1 for calling a global function with example usage: test_grid_generator_demographic_parity(grid_size, grid_limit) without return types