Skip to content

Commit

Permalink
move _htest_table to htest_table for consistency.
Browse files Browse the repository at this point in the history
  • Loading branch information
tompollard committed Jun 8, 2024
1 parent 03e730f commit e7aa792
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
22 changes: 11 additions & 11 deletions tableone/tableone.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,10 @@ def _repr_html_(self) -> str:
return self.tableone._repr_html_() + self._generate_remarks('<br />')

def initialize_core_attributes(self, data, columns, categorical, continuous, groupby,
nonnormal, min_max, pval, pval_adjust, htest_name,
htest, missing, ddof, rename, sort, limit, order,
label_suffix, decimals, smd, overall, row_percent,
dip_test, normal_test, tukey_test, pval_threshold):
nonnormal, min_max, pval, pval_adjust, htest_name,
htest, missing, ddof, rename, sort, limit, order,
label_suffix, decimals, smd, overall, row_percent,
dip_test, normal_test, tukey_test, pval_threshold):
"""
Initialize attributes.
"""
Expand Down Expand Up @@ -315,7 +315,7 @@ def initialize_intermediate_tables(self):
Initialize the intermediate tables.
"""
# Intermediate tables
self._htest_table = None
self.htest_table = None
self.cat_describe_all = None
self.cont_describe_all = None
self.cat_describe = None
Expand All @@ -340,10 +340,10 @@ def create_intermediate_tables(self, data):
"""
# forgive me jraffa
if self._pval:
self._htest_table = self.tables.create_htest_table(data, self._continuous, self._categorical,
self._nonnormal, self._groupby,
self._groupbylvls, self._htest,
self._pval, self._pval_adjust)
self.htest_table = self.tables.create_htest_table(data, self._continuous, self._categorical,
self._nonnormal, self._groupby,
self._groupbylvls, self._htest,
self._pval, self._pval_adjust)

# create overall tables if required
if self._categorical and self._groupby and self._overall:
Expand Down Expand Up @@ -400,7 +400,7 @@ def create_intermediate_tables(self, data):
self._categorical,
self._pval,
self._pval_adjust,
self._htest_table,
self.htest_table,
self._smd,
self.smd_table,
self._groupby,
Expand All @@ -414,7 +414,7 @@ def create_intermediate_tables(self, data):
self._continuous,
self._pval,
self._pval_adjust,
self._htest_table,
self.htest_table,
self._smd,
self.smd_table,
self._groupby)
Expand Down
2 changes: 1 addition & 1 deletion tableone/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Tables:
self.tables = Tables()
self.tables._create_htest_table()
self.tables._htest_table
self.tables.htest_table
"""
def __init__(self):
"""
Expand Down
10 changes: 5 additions & 5 deletions tests/unit/test_tableone.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,8 @@ def test_fisher_exact_for_small_cell_count(self, data_small):

# group2 should be tested because it's a 2x2
# group3 is a 2x3 so should not be tested
assert (table._htest_table.loc['group1', 'Test'] == "Fisher's exact")
assert (table._htest_table.loc['group3', 'Test'] ==
assert (table.htest_table.loc['group1', 'Test'] == "Fisher's exact")
assert (table.htest_table.loc['group3', 'Test'] ==
'Chi-squared (warning: expected count < 5)')

def test_sequence_of_cont_table(self, data_groups):
Expand Down Expand Up @@ -884,23 +884,23 @@ def test_custom_statistical_tests(self):
t1_diff = TableOne(data=different, columns=["val"], pval=True,
groupby="rvs", htest={"val": func})

isclose(t1_diff._htest_table['P-Value'].val,
isclose(t1_diff.htest_table['P-Value'].val,
stats.ks_2samp(rvs1, rvs2)[1])

# Table 1 for similar distributions
similar = pd.concat([df1, df3], ignore_index=True)
t1_similar = TableOne(data=similar, columns=["val"], pval=True,
groupby="rvs", htest={"val": func})

isclose(t1_similar._htest_table['P-Value'].val,
isclose(t1_similar.htest_table['P-Value'].val,
stats.ks_2samp(rvs1, rvs3)[1])

# Table 1 for identical distributions
identical = pd.concat([df1, df4], ignore_index=True)
t1_identical = TableOne(data=identical, columns=["val"], pval=True,
groupby="rvs", htest={"val": func})

isclose(t1_identical._htest_table['P-Value'].val,
isclose(t1_identical.htest_table['P-Value'].val,
stats.ks_2samp(rvs1, rvs4)[1])

def test_compute_standardized_mean_difference_continuous(self, data_pn):
Expand Down

0 comments on commit e7aa792

Please sign in to comment.