# Buggy code
def __init__(self, tables, shift_zeros=False):
    if isinstance(tables, np.ndarray):
        sp = tables.shape
        if (len(sp) != 3) or (sp[0] != 2) or (sp[1] != 2):
            raise ValueError("If an ndarray, argument must be 2x2xn")
        table = tables
    else:
        if any([np.asarray(x).shape != (2, 2) for x in tables]):
            m = "If `tables` is a list, all of its elements should be 2x2"
            raise ValueError(m)

        # Create a data cube
        table = np.dstack(tables).astype(np.float64)

    if shift_zeros:
        zx = (table == 0).sum(0).sum(0)
        ix = np.flatnonzero(zx > 0)
        if len(ix) > 0:
            table = table.copy()
            table[:, :, ix] += 0.5

    self.table = table

    self._cache = {}

    # Quantities to precompute.  Table entries are [[a, b], [c,
    # d]], 'ad' is 'a * d', 'apb' is 'a + b', 'dma' is 'd - a',
    # etc.
    self._apb = table[0, 0, :] + table[0, 1, :]
    self._apc = table[0, 0, :] + table[1, 0, :]
    self._bpd = table[0, 1, :] + table[1, 1, :]
    self._cpd = table[1, 0, :] + table[1, 1, :]
    self._ad = table[0, 0, :] * table[1, 1, :]
    self._bc = table[0, 1, :] * table[1, 0, :]
    self._apd = table[0, 0, :] + table[1, 1, :]
    self._dma = table[1, 1, :] - table[0, 0, :]
    self._n = table.sum(0).sum(0)


# Traceback (TypeError)
st.summary()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-49-bf722b7cb8e1> in <module>
----> 1 st.summary()

...\statsmodels\stats\contingency_tables.py in summary(self, alpha, float_format, method)
1270         headers = ["Statistic", "P-value", ""]
1271         stubs = ["Test of OR=1", "Test constant OR"]
-> 1272         rslt1 = self.test_null_odds()
1273         rslt2 = self.test_equal_odds()
1274         data = [[fmt(x) for x in [rslt1.statistic, rslt1.pvalue, ""]],

...\statsmodels\stats\contingency_tables.py in test_null_odds(self, correction)
1045         statistic = statistic**2
1046         denom = self._apb * self._apc * self._bpd * self._cpd
-> 1047         denom /= (self._n**2 * (self._n - 1))
1048         denom = np.sum(denom)
1049         statistic /= denom

TypeError: No loop matching the specified signature and casting
was found for ufunc true_divide

# Fixed code
def __init__(self, tables, shift_zeros=False):
    if isinstance(tables, np.ndarray):
        sp = tables.shape
        if (len(sp) != 3) or (sp[0] != 2) or (sp[1] != 2):
            raise ValueError("If an ndarray, argument must be 2x2xn")
        table = tables * 1.0  # use atleast float dtype
    else:
        if any([np.asarray(x).shape != (2, 2) for x in tables]):
            m = "If `tables` is a list, all of its elements should be 2x2"
            raise ValueError(m)

        # Create a data cube
        table = np.dstack(tables).astype(np.float64)

    if shift_zeros:
        zx = (table == 0).sum(0).sum(0)
        ix = np.flatnonzero(zx > 0)
        if len(ix) > 0:
            table = table.copy()
            table[:, :, ix] += 0.5

    self.table = table

    self._cache = {}

    # Quantities to precompute.  Table entries are [[a, b], [c,
    # d]], 'ad' is 'a * d', 'apb' is 'a + b', 'dma' is 'd - a',
    # etc.
    self._apb = table[0, 0, :] + table[0, 1, :]
    self._apc = table[0, 0, :] + table[1, 0, :]
    self._bpd = table[0, 1, :] + table[1, 1, :]
    self._cpd = table[1, 0, :] + table[1, 1, :]
    self._ad = table[0, 0, :] * table[1, 1, :]
    self._bc = table[0, 1, :] * table[1, 0, :]
    self._apd = table[0, 0, :] + table[1, 1, :]
    self._dma = table[1, 1, :] - table[0, 0, :]
    self._n = table.sum(0).sum(0)