Skip to content

Commit

Permalink
TST: Add test for correct row ordering
Browse files Browse the repository at this point in the history
Add test to verify summary_col preserved order

closes statsmodels#3767
  • Loading branch information
bashtage committed Oct 25, 2017
1 parent 82dc880 commit 889d437
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions statsmodels/iolib/tests/test_summary2.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,27 @@ def test_summarycol_drop_omitted(self):
assert 'const' in str(actual)
assert 'x2' in str(actual)

def test_summary_col_ordering_preserved(self):
# gh-3767
x = [1, 5, 7, 3, 5]
x = add_constant(x)
x2 = np.concatenate([x, np.array([[3], [9], [-1], [4], [0]])], 1)
y1 = [6, 4, 2, 7, 4]
y2 = [8, 5, 0, 12, 4]
reg1 = OLS(y1, x2).fit()
reg2 = OLS(y2, x2).fit()
info_dict = {'R2': lambda x: '{:.3f}'.format(int(x.rsquared)),
'N': lambda x: '{0:d}'.format(int(x.nobs))}
original = actual = summary_col([reg1, reg2], float_format='%0.4f')
actual = summary_col([reg1, reg2], regressor_order=['x2', 'x1'],
float_format='%0.4f',
info_dict=info_dict)
variables = ('const', 'x1', 'x2')
for line in str(original).split('\n'):
for variable in variables:
if line.startswith(variable):
assert line in str(actual)

def test_OLSsummary(self):
# Test that latex output of regular OLS output still contains
# multiple tables
Expand Down

0 comments on commit 889d437

Please sign in to comment.