def test_skips_class_when_calibration_parameters_not_present(self):
    'Tests that graph fails when parameters not present for all classes.'
    class_0_x = np.asarray([0.0, 0.5, 1.0])
    class_0_y = np.asarray([0.5, 0.5, 0.5])
    calibration_config = calibration_pb2.CalibrationConfig()
    self._add_function_approximation_to_calibration_proto(calibration_config, class_0_x, class_0_y, class_id=0)

    def graph_fn():
        calibration_fn = calibration_builder.build(calibration_config)
        class_predictions_with_background = tf.constant([[[0.1, 0.2], [0.9, 0.1]], [[0.6, 0.4], [0.08, 0.92]]], dtype=tf.float32)
        calibrated_scores = calibration_fn(class_predictions_with_background)
        return calibrated_scores
    calibrated_scores_np = self.execute(graph_fn, [])
    self.assertAllClose(calibrated_scores_np, [[[0.5, 0.2], [0.5, 0.1]], [[0.5, 0.4], [0.5, 0.92]]])
Tests that graph fails when parameters not present for all classes.
def test_skips_class_when_calibration_parameters_not_present(self):
    
    class_0_x = np.asarray([0.0, 0.5, 1.0])
    class_0_y = np.asarray([0.5, 0.5, 0.5])
    calibration_config = calibration_pb2.CalibrationConfig()
    self._add_function_approximation_to_calibration_proto(calibration_config, class_0_x, class_0_y, class_id=0)

    def graph_fn():
        calibration_fn = calibration_builder.build(calibration_config)
        class_predictions_with_background = tf.constant([[[0.1, 0.2], [0.9, 0.1]], [[0.6, 0.4], [0.08, 0.92]]], dtype=tf.float32)
        calibrated_scores = calibration_fn(class_predictions_with_background)
        return calibrated_scores
    calibrated_scores_np = self.execute(graph_fn, [])
    self.assertAllClose(calibrated_scores_np, [[[0.5, 0.2], [0.5, 0.1]], [[0.5, 0.4], [0.5, 0.92]]])