Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.

Commit c35536d

Browse files
authored
Fixes #50 - summary() fails if called a second time. (#107)
* Fixes #50 - summary() fails if called a second time.
1 parent b5eb937 commit c35536d

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/python/nimbusml/base_predictor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def summary(self):
139139
"""
140140
Returns model summary.
141141
"""
142-
if hasattr(self, 'model_summary_') and self.model_summary_:
142+
if hasattr(self, 'model_summary_') and self.model_summary_ is not None:
143143
return self.model_summary_
144144

145145
if not hasattr(

src/python/nimbusml/tests/model_summary/test_model_summary.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,17 @@ def test_model_summary_not_supported(self):
112112
pipeline.fit(train_stream, label_column)
113113
assert_raises(TypeError, pipeline.summary)
114114

115+
def test_summary_called_back_to_back_on_predictor(self):
116+
"""
117+
When a predictor is fit without using a Pipeline,
118+
calling summary() more than once should not throw
119+
an exception.
120+
"""
121+
ols = OrdinaryLeastSquaresRegressor()
122+
ols.fit([1,2,3,4], [2,4,6,7])
123+
ols.summary()
124+
ols.summary()
125+
115126

116127
if __name__ == '__main__':
117128
unittest.main()

0 commit comments

Comments
 (0)