Skip to content

Commit

Permalink
Merge pull request #1192 from astaric/bug-blaz
Browse files Browse the repository at this point in the history
[FIX] Transformation: fix a bug in nested transformation of instance
  • Loading branch information
kernc committed Apr 19, 2016
2 parents 66e7cec + a8d3444 commit b0de39a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Orange/preprocess/transformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __call__(self, data):
else:
data = data.get_column_view(self.attr_index)[0]
transformed = self.transform(data)
if inst and isinstance(transformed, np.ndarray):
if inst and isinstance(transformed, np.ndarray) and transformed.shape:
transformed = transformed[0]
return transformed

Expand Down
8 changes: 8 additions & 0 deletions Orange/tests/test_logistic_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class LogisticRegressionTest(unittest.TestCase):
def setUpClass(cls):
cls.iris = Table('iris')
cls.voting = Table('voting')
cls.zoo = Table('zoo')

def test_LogisticRegression(self):
learn = LogisticRegressionLearner()
Expand Down Expand Up @@ -70,3 +71,10 @@ def test_coefficients(self):
model = learn(self.voting)
coef = model.coefficients
self.assertEqual(len(coef[0]), len(model.domain.attributes))

def test_predict_on_instance(self):
lr = LogisticRegressionLearner()
m = lr(self.zoo)
probs = m(self.zoo[50], m.Probs)
probs2 = m(self.zoo[50, :], m.Probs)
np.testing.assert_almost_equal(probs, probs2)

0 comments on commit b0de39a

Please sign in to comment.