Skip to content

Commit 7504b9d

Browse files
authored
Merge pull request #3163 from thocevar/removeconstant
[FIX] RemoveConstant: remove constant NaN features.
2 parents 701517c + da878bb commit 7504b9d

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

Orange/preprocess/preprocess.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,8 @@ def __call__(self, data):
190190
data : an input dataset
191191
"""
192192

193-
oks = bn.nanmin(data.X, axis=0) != \
194-
bn.nanmax(data.X, axis=0)
193+
oks = np.logical_and(~bn.allnan(data.X, axis=0),
194+
bn.nanmin(data.X, axis=0) != bn.nanmax(data.X, axis=0))
195195
atts = [data.domain.attributes[i] for i, ok in enumerate(oks) if ok]
196196
domain = Orange.data.Domain(atts, data.domain.class_vars,
197197
data.domain.metas)

Orange/tests/test_preprocess.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,11 @@ def test_refuse_data_in_constructor(self):
6161

6262
class TestRemoveConstant(unittest.TestCase):
6363
def test_remove_columns(self):
64-
X = np.random.rand(6, 4)
64+
X = np.random.rand(6, 5)
6565
X[:, (1,3)] = 5
6666
X[3, 1] = np.nan
6767
X[1, 1] = np.nan
68+
X[:, 4] = np.nan
6869
data = Table(X)
6970
d = RemoveConstant()(data)
7071
self.assertEqual(len(d.domain.attributes), 2)

0 commit comments

Comments
 (0)