Skip to content

Commit

Permalink
add error message when features are empty
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeLing committed Jun 30, 2017
1 parent 5a2d6e1 commit 2f3e649
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 2f3e649

Please sign in to comment.