Skip to content

Commit

Permalink
Merge pull request #3163 from thocevar/removeconstant
Browse files Browse the repository at this point in the history
[FIX] RemoveConstant: remove constant NaN features.
  • Loading branch information
lanzagar authored Jul 31, 2018
2 parents 701517c + da878bb commit 7504b9d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Orange/preprocess/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ def __call__(self, data):
data : an input dataset
"""

oks = bn.nanmin(data.X, axis=0) != \
bn.nanmax(data.X, axis=0)
oks = np.logical_and(~bn.allnan(data.X, axis=0),
bn.nanmin(data.X, axis=0) != bn.nanmax(data.X, axis=0))
atts = [data.domain.attributes[i] for i, ok in enumerate(oks) if ok]
domain = Orange.data.Domain(atts, data.domain.class_vars,
data.domain.metas)
Expand Down
3 changes: 2 additions & 1 deletion Orange/tests/test_preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ def test_refuse_data_in_constructor(self):

class TestRemoveConstant(unittest.TestCase):
def test_remove_columns(self):
X = np.random.rand(6, 4)
X = np.random.rand(6, 5)
X[:, (1,3)] = 5
X[3, 1] = np.nan
X[1, 1] = np.nan
X[:, 4] = np.nan
data = Table(X)
d = RemoveConstant()(data)
self.assertEqual(len(d.domain.attributes), 2)
Expand Down

0 comments on commit 7504b9d

Please sign in to comment.