code: def test_tree_one_split(veterans):
      X, y = veterans
      X = X.loc[:, "Karnofsky_score"].values[:, np.newaxis]
  
      tree = SurvivalTree(max_depth=1)
      tree.fit(X, y)
  
      stats = LogrankTreeBuilder(max_depth=1).build(X, y)
  
      assert tree.tree_.capacity == stats.shape[0]
      assert_array_equal(
          tree.tree_.feature, stats.loc[:, "feature"].values
      )
      assert_array_equal(
          tree.tree_.n_node_samples,
          stats.loc[:, "n_node_samples"].values,
      )
      assert_array_almost_equal(
          tree.tree_.threshold, stats.loc[:, "threshold"].values
      )
  
      expected_time = np.array(
          [
              1,
              2,
              3,
              4,
              7,
              8,
              10,
              11,
              12,
              13,
              15,
              16,
              18,
              19,
              20,
              21,
              22,
              24,
              25,
              27,
              29,
              30,
              31,
              33,
              35,
              36,
              42,
              43,
              44,
              45,
              48,
              49,
              51,
              52,
              53,
              54,
              56,
              59,
              61,
              63,
              72,
              73,
              80,
              82,
              83,
              84,
              87,
              90,
              92,
              95,
              97,
              99,
              100,
              103,
              105,
              110,
              111,
              112,
              117,
              118,
              122,
              123,
              126,
              132,
              133,
              139,
              140,
              143,
              144,
              151,
              153,
              156,
              162,
              164,
              177,
              182,
              186,
              200,
              201,
              216,
              228,
              231,
              242,
              250,
              260,
              278,
              283,
              287,
              314,
              340,
              357,
              378,
              384,
              389,
              392,
              411,
              467,
              553,
              587,
              991,
              999,
          ],
          dtype=float,
      )
      assert_array_equal(tree.unique_times_, expected_time)
      assert_array_equal(
          tree.unique_times_[~tree.is_event_time_],
          np.array([83, 97, 123, 182], dtype=float),
      )
  
      threshold = stats.loc[0, "threshold"]
      m = X[:, 0] <= threshold
      y_left = y[m]
      _, chf_left = nelson_aalen_estimator(
          y_left["Status"], y_left["Survival_in_days"]
      )
  
      y_right = y[~m]
      _, chf_right = nelson_aalen_estimator(
          y_right["Status"], y_right["Survival_in_days"]
      )
  
      X_pred = np.array([[threshold - 10], [threshold + 10]])
      chf_pred = tree.predict_cumulative_hazard_function(
          X_pred, return_array=True
      )
  
      assert_curve_almost_equal(chf_pred[0], chf_left)
      assert_curve_almost_equal(chf_pred[1], chf_right)
  
      mrt_pred = tree.predict(X_pred)
      assert_array_almost_equal(
          mrt_pred, np.array([196.55878, 86.14939])
      )
  
      _, surv_left = kaplan_meier_estimator(
          y_left["Status"], y_left["Survival_in_days"]
      )
      _, surv_right = kaplan_meier_estimator(
          y_right["Status"], y_right["Survival_in_days"]
      )
  
      surv_pred = tree.predict_survival_function(
          X_pred, return_array=True
      )
  
      assert_curve_almost_equal(surv_pred[0], surv_left)
      assert_curve_almost_equal(surv_pred[1], surv_right)
  
imports: from itertools import product
  from queue import LifoQueue
  import numpy
  from numpy.testing import assert_array_almost_equal, assert_array_equal
  import pandas
  import pytest
  from scipy import sparse
  from sklearn.model_selection import train_test_split
  from sklearn.pipeline import make_pipeline
  from sklearn.preprocessing import OrdinalEncoder
  from sklearn.tree._tree import TREE_UNDEFINED
  from sksurv.compare import compare_survival
  from sksurv.datasets import load_breast_cancer, load_veterans_lung_cancer
  from sksurv.nonparametric import kaplan_meier_estimator, nelson_aalen_estimator
  from sksurv.tree import SurvivalTree
  from sksurv.util import Surv
label_desc: Use image node_id 6 for calling a global function with example usage: test_tree_one_split(veterans) without return types