code: def test_construct_and_load():
      eqo = EqualizedOdds()
      assert eqo.short_name == "EqualizedOdds"
  
      # Generate some rigged data
      num_samples_a0 = 10
      num_samples_a1 = 30
      num_samples = num_samples_a0 + num_samples_a1
  
      a0_threshold = 0.2
      a1_threshold = 0.7
  
      a0_label = 0xBEEF
      a1_label = 0xDEAD
  
      X, Y, A = simple_binary_threshold_data(
          num_samples_a0,
          num_samples_a1,
          a0_threshold,
          a1_threshold,
          a0_label,
          a1_label,
      )
  
      # Load up the (rigged) data
      eqo.load_data(X, Y, sensitive_features=A)
      assert eqo.data_loaded
      assert eqo.total_samples == num_samples_a0 + num_samples_a1
  
      # Examine the tags DF
      assert eqo.tags["label"].equals(pd.Series(Y))
      assert eqo.tags["group_id"].equals(pd.Series(A))
      expected_tags_event = ["label={0}".format(a) for a in Y]
      assert np.array_equal(expected_tags_event, eqo.tags["event"])
  
      # Examine the index MultiIndex
      events = ["label=False", "label=True"]
      signs = ["+", "-"]
      labels = [a0_label, a1_label]
      expected_index = pd.MultiIndex.from_product(
          [signs, events, labels], names=[_SIGN, _EVENT, _GROUP_ID]
      )
      assert eqo.index.equals(expected_index)
  
      # Examine the prob_event DF
      # There are two events - 'True' and 'False'
      assert len(eqo.prob_event.index) == 2
      assert eqo.prob_event.loc["label=False"] == 1 - sum(Y) / len(Y)
      assert eqo.prob_event.loc["label=True"] == sum(Y) / len(Y)
  
      # Examine the prob_group_event DF
      # There's only an 'all' event but this records the fractions
      # of each label in the population
      assert len(eqo.prob_group_event.index) == 4
      # Use the fact that our data are uniformly distributed in the range [0, 1]
      # With the current values, it appears we don't need to fiddle for off-by-one cases
      a0_below = a0_threshold * num_samples_a0
      a0_above = num_samples_a0 - a0_below
      assert (
          eqo.prob_group_event.loc[("label=False", a0_label)]
          == a0_below / num_samples
      )
      assert (
          eqo.prob_group_event.loc[("label=True", a0_label)]
          == a0_above / num_samples
      )
      a1_below = a1_threshold * num_samples_a1
      a1_above = num_samples_a1 - a1_below
      assert (
          eqo.prob_group_event.loc[("label=False", a1_label)]
          == a1_below / num_samples
      )
      assert (
          eqo.prob_group_event.loc[("label=True", a1_label)]
          == a1_above / num_samples
      )
  
      # Examine the neg_basis DF
      assert len(eqo.neg_basis.index) == 8
      assert eqo.neg_basis[0]["+", "label=False", a0_label] == 0
      assert eqo.neg_basis[0]["+", "label=False", a1_label] == 0
      assert eqo.neg_basis[0]["+", "label=True", a0_label] == 0
      assert eqo.neg_basis[0]["+", "label=True", a1_label] == 0
      assert eqo.neg_basis[0]["-", "label=False", a0_label] == 1
      assert eqo.neg_basis[0]["-", "label=False", a1_label] == 0
      assert eqo.neg_basis[0]["-", "label=True", a0_label] == 0
      assert eqo.neg_basis[0]["-", "label=True", a1_label] == 0
  
      # Examine the pos_basis DF
      # This is looking at the \lambda_{+} values and picking out the
      # one associated with the first label
      assert len(eqo.pos_basis.index) == 8
      assert eqo.pos_basis[0]["+", "label=False", a0_label] == 1
      assert eqo.pos_basis[0]["+", "label=False", a1_label] == 0
      assert eqo.pos_basis[0]["+", "label=True", a0_label] == 0
      assert eqo.pos_basis[0]["+", "label=True", a1_label] == 0
      assert eqo.pos_basis[0]["-", "label=False", a0_label] == 0
      assert eqo.pos_basis[0]["-", "label=False", a1_label] == 0
      assert eqo.pos_basis[0]["-", "label=True", a0_label] == 0
      assert eqo.pos_basis[0]["-", "label=True", a1_label] == 0
  
      # Examine the neg_basis_present DF
      assert len(eqo.neg_basis_present) == 2
      assert eqo.neg_basis_present[0]
      assert eqo.neg_basis_present[1]
  
file_path: fairlearn/test/unit/reductions/moments/test_moments_equalized_odds.py
imports: import numpy
  import pandas
  from fairlearn.reductions import EqualizedOdds
  from fairlearn.reductions._moments.moment import _EVENT, _GROUP_ID, _SIGN
  from .data_generator import simple_binary_threshold_data
label_desc: Use image node_id 1 for calling a global function with example usage: test_construct_and_load() without return types