Skip to content

Commit dc5196a

Browse files
committed
Used np.vectorize to strip the excess string identfiers and switch from string check to integer check for counts.
1 parent 9c020e0 commit dc5196a

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

statsmodels/genmod/tests/results/results_glm.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,9 @@ def __init__(self):
684684
# data set up for data not in datasets
685685
filename = os.path.join(os.path.dirname(os.path.abspath(__file__)),
686686
"stata_lbw_glm.csv")
687-
data=np.recfromcsv(open(filename, 'rb'), converters={4: lambda s: s.strip(asbytes("\""))})
687+
data=np.recfromcsv(open(filename, 'rb'))
688+
vfunc = np.vectorize(lambda x: x.strip(asbytes("\"")))
689+
data['race'] = vfunc(data['race'])
688690
data = categorical(data, col='race', drop=True)
689691
self.endog = data.low
690692
design = np.column_stack((data['age'], data['lwt'],
@@ -2191,7 +2193,9 @@ class Medpar1(object):
21912193
def __init__(self):
21922194
filename = os.path.join(os.path.dirname(os.path.abspath(__file__)),
21932195
"stata_medpar1_glm.csv")
2194-
data = np.recfromcsv(open(filename, 'rb'), converters ={1: lambda s: s.strip(asbytes("\""))})
2196+
data = np.recfromcsv(open(filename, 'rb'))
2197+
vfunc = np.vectorize(lambda x: x.strip(asbytes('\"')))
2198+
data['admitype'] = vfunc(data['admitype'])
21952199
self.endog = data.los
21962200
design = np.column_stack((data.admitype, data.codes))
21972201
design = categorical(design, col=0, drop=True)

statsmodels/stats/tests/test_contingency_tables.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ def test_SquareTable_from_data():
6161
rslt3.summary().as_text())
6262

6363
s = str(rslt1)
64-
assert_equal(s.startswith('A 5x5 contingency table with counts:\n[[ 8.'), True)
64+
assert_equal(s.startswith('A 5x5 contingency table with counts:'), True)
65+
assert_equal(rslt1.table[0, 0], 8.)
6566

6667

6768
def test_SquareTable_nonsquare():

0 commit comments

Comments
 (0)