code: def test_survdiff():
      # Results come from R survival and survMisc packages (survMisc is
      # used for non G-rho family tests but does not seem to support
      # stratification)
  
      full_df = bmt.copy()
      df = bmt[bmt.Group != "ALL"].copy()
  
      # Not stratified
      stat, p = survdiff(df["T"], df.Status, df.Group)
      assert_allclose(stat, 13.44556, atol=1e-4, rtol=1e-4)
      stat, p = survdiff(df["T"], df.Status, df.Group, weight_type="gb")
      assert_allclose(stat, 15.38787, atol=1e-4, rtol=1e-4)
      stat, p = survdiff(df["T"], df.Status, df.Group, weight_type="tw")
      assert_allclose(stat, 14.98382, atol=1e-4, rtol=1e-4)
      stat, p = survdiff(
          df["T"], df.Status, df.Group, weight_type="fh", fh_p=0.5
      )
      assert_allclose(stat, 14.46866, atol=1e-4, rtol=1e-4)
      stat, p = survdiff(
          df["T"], df.Status, df.Group, weight_type="fh", fh_p=1
      )
      assert_allclose(stat, 14.84500, atol=1e-4, rtol=1e-4)
  
      # Not stratified, >2 groups
      stat, p = survdiff(
          full_df["T"],
          full_df.Status,
          full_df.Group,
          weight_type="fh",
          fh_p=1,
      )
      assert_allclose(stat, 15.67247, atol=1e-4, rtol=1e-4)
  
      # 5 strata
      strata = np.arange(df.shape[0]) % 5
      df["strata"] = strata
      stat, p = survdiff(df["T"], df.Status, df.Group, strata=df.strata)
      assert_allclose(stat, 11.97799, atol=1e-4, rtol=1e-4)
      stat, p = survdiff(
          df["T"],
          df.Status,
          df.Group,
          strata=df.strata,
          weight_type="fh",
          fh_p=0.5,
      )
      assert_allclose(stat, 12.6257, atol=1e-4, rtol=1e-4)
      stat, p = survdiff(
          df["T"],
          df.Status,
          df.Group,
          strata=df.strata,
          weight_type="fh",
          fh_p=1,
      )
      assert_allclose(stat, 12.73565, atol=1e-4, rtol=1e-4)
  
      # 5 strata, >2 groups
      full_strata = np.arange(full_df.shape[0]) % 5
      full_df["strata"] = full_strata
      stat, p = survdiff(
          full_df["T"],
          full_df.Status,
          full_df.Group,
          strata=full_df.strata,
          weight_type="fh",
          fh_p=0.5,
      )
      assert_allclose(stat, 13.56793, atol=1e-4, rtol=1e-4)
  
      # 8 strata
      df["strata"] = np.arange(df.shape[0]) % 8
      stat, p = survdiff(df["T"], df.Status, df.Group, strata=df.strata)
      assert_allclose(stat, 12.12631, atol=1e-4, rtol=1e-4)
      stat, p = survdiff(
          df["T"],
          df.Status,
          df.Group,
          strata=df.strata,
          weight_type="fh",
          fh_p=0.5,
      )
      assert_allclose(stat, 12.9633, atol=1e-4, rtol=1e-4)
      stat, p = survdiff(
          df["T"],
          df.Status,
          df.Group,
          strata=df.strata,
          weight_type="fh",
          fh_p=1,
      )
      assert_allclose(stat, 13.35259, atol=1e-4, rtol=1e-4)
  
imports: import os
  import numpy
  from statsmodels.duration.survfunc import SurvfuncRight, survdiff, plot_survfunc, CumIncidenceRight
  from numpy.testing import assert_allclose
  import pandas
  import pytest
label_desc: Use image node_id 7 for calling a global function with example usage: test_survdiff() without return types