code: def test_constraints_objective_pairs(constraints, objective):
      X = pd.Series([0, 1, 2, 3, 4, 0, 1, 2, 3]).to_frame()
      sf = pd.Series([0, 0, 0, 0, 0, 1, 1, 1, 1])
      y = pd.Series([1, 0, 1, 1, 1, 0, 1, 1, 1])
      thr_optimizer = ThresholdOptimizer(
          estimator=PassThroughPredictor(),
          constraints=constraints,
          objective=objective,
          grid_size=20,
          predict_method="predict",
      )
      expected = results[constraints + ", " + objective]
      if type(expected) is str:
          with pytest.raises(ValueError) as error_info:
              thr_optimizer.fit(X, y, sensitive_features=sf)
          assert str(error_info.value).startswith(expected)
      else:
          thr_optimizer.fit(X, y, sensitive_features=sf)
          res = (
              thr_optimizer.interpolated_thresholder_.interpolation_dict
          )
          for key in [0, 1]:
              assert res[key]["p0"] == pytest.approx(
                  expected[key]["p0"], PREC
              )
              assert (
                  res[key]["operation0"]._operator
                  == expected[key]["op0"]
              )
              assert res[key]["operation0"]._threshold == pytest.approx(
                  expected[key]["thr0"], PREC
              )
              assert res[key]["p1"] == pytest.approx(
                  expected[key]["p1"], PREC
              )
              assert (
                  res[key]["operation1"]._operator
                  == expected[key]["op1"]
              )
              assert res[key]["operation1"]._threshold == pytest.approx(
                  expected[key]["thr1"], PREC
              )
              if "p_ignore" in expected[key]:
                  assert res[key]["p_ignore"] == pytest.approx(
                      expected[key]["p_ignore"], PREC
                  )
                  assert res[key][
                      "prediction_constant"
                  ] == pytest.approx(
                      expected[key]["prediction_constant"], PREC
                  )
              else:
                  assert "p_ignore" not in res[key]
  
imports: from copy import deepcopy
  from test.unit.input_convertors import _map_into_single_column
  import numpy
  import pandas
  import pytest
  from sklearn.base import BaseEstimator, ClassifierMixin
  from sklearn.datasets import make_classification
  from fairlearn.postprocessing import ThresholdOptimizer
  from fairlearn.postprocessing._threshold_optimizer import BASE_ESTIMATOR_NONE_ERROR_MESSAGE, NOT_SUPPORTED_CONSTRAINTS_ERROR_MESSAGE
  from fairlearn.postprocessing._tradeoff_curve_utilities import DEGENERATE_LABELS_ERROR_MESSAGE
  from fairlearn.utils._input_validation import _LABELS_NOT_0_1_ERROR_MESSAGE, _MESSAGE_SENSITIVE_FEATURES_NONE, _MESSAGE_Y_NONE
  from .conftest import ExamplePredictor, X_ex, _get_predictions_by_sensitive_feature, candidate_A_transforms, candidate_X_transforms, candidate_Y_transforms, degenerate_labels_ex, is_invalid_transformation, labels_ex, scores_ex, sensitive_feature_names_ex1, sensitive_features_ex1
label_desc: Use image node_id 14 for calling a global function with example usage: test_constraints_objective_pairs(constraints, objective) without return types