Skip to content

Commit

Permalink
Merge pull request #3887 from MikeLing/issuefix-3884
Browse files Browse the repository at this point in the history
add error message when features are empty
  • Loading branch information
vigsterkr committed Jun 30, 2017
2 parents 04db0fc + 2f3e649 commit a592dd9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/shogun/converter/ica/FastICA.cpp
Expand Up @@ -76,6 +76,7 @@ CFeatures* CFastICA::apply(CFeatures* features)
SG_REF(features);

SGMatrix<float64_t> X = ((CDenseFeatures<float64_t>*)features)->get_feature_matrix();
REQUIRE(X.data(), "Features have not been provided.\n");

int n = X.num_rows;
int p = X.num_cols;
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/converter/ica/FastICA_unittest.cc
Expand Up @@ -61,3 +61,11 @@ TEST(CFastICA, blind_source_separation)
SG_UNREF(signals);
}

TEST(CFastICA, with_empty_feature)
{
CDenseFeatures<float64_t>* empty_feat = new CDenseFeatures<float64_t>();
CFastICA* ica = new CFastICA();
EXPECT_THROW(ica->apply(empty_feat), ShogunException);
SG_UNREF(ica);
SG_UNREF(empty_feat);
}

0 comments on commit a592dd9

Please sign in to comment.