code: def test_twosample_poisson_r():
      # testing against R package `exactci
      from .results.results_rates import (
          res_pexact_cond,
          res_pexact_cond_midp,
      )
  
      # example 1 from Gu
      count1, n1, count2, n2 = 60, 51477.5, 30, 54308.7
  
      res2 = res_pexact_cond
      res1 = smr.test_poisson_2indep(
          count1, n1, count2, n2, method="exact-cond"
      )
      assert_allclose(res1.pvalue, res2.p_value, rtol=1e-13)
      assert_allclose(res1.ratio, res2.estimate, rtol=1e-13)
      assert_equal(res1.ratio_null, res2.null_value)
  
      res2 = res_pexact_cond_midp
      res1 = smr.test_poisson_2indep(
          count1, n1, count2, n2, method="cond-midp"
      )
      assert_allclose(res1.pvalue, res2.p_value, rtol=0, atol=5e-6)
      assert_allclose(res1.ratio, res2.estimate, rtol=1e-13)
      assert_equal(res1.ratio_null, res2.null_value)
  
      # one-sided
      # > pe = poisson.exact(c(60, 30), c(51477.5, 54308.7), r=1.2,
      #                      alternative="less", tsmethod="minlike", midp=TRUE)
      # > pe$p.value
      pv2 = 0.9949053964701466
      rest = smr.test_poisson_2indep(
          count1,
          n1,
          count2,
          n2,
          method="cond-midp",
          value=1.2,
          alternative="smaller",
      )
      assert_allclose(rest.pvalue, pv2, rtol=1e-12)
      # > pe = poisson.exact(c(60, 30), c(51477.5, 54308.7), r=1.2,
      #           alternative="greater", tsmethod="minlike", midp=TRUE)
      # > pe$p.value
      pv2 = 0.005094603529853279
      rest = smr.test_poisson_2indep(
          count1,
          n1,
          count2,
          n2,
          method="cond-midp",
          value=1.2,
          alternative="larger",
      )
      assert_allclose(rest.pvalue, pv2, rtol=1e-12)
      # > pe = poisson.exact(c(60, 30), c(51477.5, 54308.7), r=1.2,
      #           alternative="greater", tsmethod="minlike", midp=FALSE)
      # > pe$p.value
      pv2 = 0.006651774552714537
      rest = smr.test_poisson_2indep(
          count1,
          n1,
          count2,
          n2,
          method="exact-cond",
          value=1.2,
          alternative="larger",
      )
      assert_allclose(rest.pvalue, pv2, rtol=1e-12)
      # > pe = poisson.exact(c(60, 30), c(51477.5, 54308.7), r=1.2,
      #                      alternative="less", tsmethod="minlike", midp=FALSE)
      # > pe$p.value
      pv2 = 0.9964625674930079
      rest = smr.test_poisson_2indep(
          count1,
          n1,
          count2,
          n2,
          method="exact-cond",
          value=1.2,
          alternative="smaller",
      )
      assert_allclose(rest.pvalue, pv2, rtol=1e-12)
  
imports: import pytest
  import warnings
  import numpy
  from numpy import arange
  from numpy.testing import assert_allclose, assert_equal
  from scipy import stats
  import statsmodels.stats.rates
  from statsmodels.stats.rates import confint_poisson, tolerance_int_poisson, confint_quantile_poisson, etest_poisson_2indep, confint_poisson_2indep, nonequivalence_poisson_2indep, power_poisson_ratio_2indep, power_equivalence_poisson_2indep, power_poisson_diff_2indep, power_equivalence_neginb_2indep, power_negbin_ratio_2indep, method_names_poisson_1samp, method_names_poisson_2indep
label_desc: Use image node_id 9 for calling a global function with example usage: test_twosample_poisson_r() without return types