Skip to content

Commit

Permalink
fix type error.
Browse files Browse the repository at this point in the history
  • Loading branch information
tompollard committed Jun 7, 2024
1 parent 312f882 commit 53a1824
Showing 1 changed file with 38 additions and 37 deletions.
75 changes: 38 additions & 37 deletions tableone/tableone.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,44 +446,45 @@ def _generate_remarks(self, newline='\n') -> str:
Generate a series of remarks that the user should consider
when interpreting the summary statistics.
"""
# generate warnings for continuous variables
if self._continuous and self._tukey_test:
# highlight far outliers
outlier_mask = self.cont_describe.far_outliers > 1
outlier_vars = list(self.cont_describe.far_outliers[outlier_mask].
if self.cont_describe is not None:
# generate warnings for continuous variables
if self._continuous and self._tukey_test:
# highlight far outliers
outlier_mask = self.cont_describe.far_outliers > 1
outlier_vars = list(self.cont_describe.far_outliers[outlier_mask].
dropna(how='all').index)
if outlier_vars:
self._warnings["""Tukey test indicates far outliers
in"""] = outlier_vars

if self._continuous and self._dip_test:
# highlight possible multimodal distributions using hartigan's dip
# test -1 values indicate NaN
modal_mask = ((self.cont_describe.hartigan_dip >= 0) &
(self.cont_describe.hartigan_dip <= 0.05))
modal_vars = list(self.cont_describe.hartigan_dip[modal_mask].
dropna(how='all').index)
if outlier_vars:
self._warnings["""Tukey test indicates far outliers
in"""] = outlier_vars

if self._continuous and self._dip_test:
# highlight possible multimodal distributions using hartigan's dip
# test -1 values indicate NaN
modal_mask = ((self.cont_describe.hartigan_dip >= 0) &
(self.cont_describe.hartigan_dip <= 0.05))
modal_vars = list(self.cont_describe.hartigan_dip[modal_mask].
dropna(how='all').index)
if modal_vars:
self._warnings["""Hartigan's Dip Test reports possible
multimodal distributions for"""] = modal_vars

if self._continuous and self._normal_test:
# highlight non normal distributions
# -1 values indicate NaN
modal_mask = ((self.cont_describe.normality >= 0) &
(self.cont_describe.normality <= 0.001))
modal_vars = list(self.cont_describe.normality[modal_mask].
dropna(how='all').index)
if modal_vars:
self._warnings["""Normality test reports non-normal
distributions for"""] = modal_vars

# create the warning string
msg = '{}'.format(newline)
for n, k in enumerate(sorted(self._warnings)):
msg += '[{}] {}: {}.{}'.format(n+1, k,
', '.join(self._warnings[k]),
newline)
if modal_vars:
self._warnings["""Hartigan's Dip Test reports possible
multimodal distributions for"""] = modal_vars

if self._continuous and self._normal_test:
# highlight non normal distributions
# -1 values indicate NaN
modal_mask = ((self.cont_describe.normality >= 0) &
(self.cont_describe.normality <= 0.001))
modal_vars = list(self.cont_describe.normality[modal_mask].
dropna(how='all').index)
if modal_vars:
self._warnings["""Normality test reports non-normal
distributions for"""] = modal_vars

# create the warning string
msg = '{}'.format(newline)
for n, k in enumerate(sorted(self._warnings)):
msg += '[{}] {}: {}.{}'.format(n+1, k, ', '.join(self._warnings[k]), newline)
else:
msg = ""

return msg

Expand Down

0 comments on commit 53a1824

Please sign in to comment.