code: def test_study_finalize():
      s = get_mock_study()
  
      t = s.get_suggestion()
      assert t.id == 1
      assert t.parameters == {"a": 1, "b": 2}
      s.algorithm.get_suggestion.assert_called_with(
          s.parameters, s.results, s.lower_is_better
      )
  
      s.add_observation(
          trial=t,
          iteration=1,
          objective=0.1,
          context={"other_metrics": 0.2},
      )
      s.add_observation(
          trial=t,
          iteration=2,
          objective=0.01,
          context={"other_metrics": 0.02},
      )
      s.finalize(trial=t, status="COMPLETED")
  
      expected_df = pandas.DataFrame(
          collections.OrderedDict(
              [
                  ("Trial-ID", [1, 1, 1]),
                  (
                      "Status",
                      ["INTERMEDIATE", "INTERMEDIATE", "COMPLETED"],
                  ),
                  ("Iteration", [1, 2, 2]),
                  ("a", [1, 1, 1]),
                  ("b", [2, 2, 2]),
                  ("Objective", [0.1, 0.01, 0.01]),
                  ("other_metrics", [0.2, 0.02, 0.02]),
              ]
          )
      )
  
      assert s.results.equals(expected_df)
  
file_path: sherpa/tests/test_study.py
imports: import pytest
  import sherpa
  import sherpa.core
  import sherpa.schedulers
  import sherpa.database
  import pandas
  import collections
  from testing_utils import *
label_desc: Use image node_id 7 for calling a global function with example usage: test_study_finalize() without return types