Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
nomad-lab
cpp_sisso
Commits
727dcd94
Commit
727dcd94
authored
Sep 10, 2021
by
Thomas Purcell
Browse files
Add tests for MPI-op
Since MPI is not being used in the runners
parent
d7b01807
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/feature_creation/feature_space/FeatureSpace.cpp
View file @
727dcd94
...
...
@@ -1061,11 +1061,11 @@ void FeatureSpace::sis(std::shared_ptr<LossFunction> loss)
// Generate features on the fly and get the best features for this rank
if
(
_n_rung_generate
>
0
)
{
#ifdef PARAMETERIZE
#ifdef PARAMETERIZE
_phi
.
resize
(
_n_feat
);
_phi
.
insert
(
_phi
.
end
(),
_phi_reparam
.
begin
()
+
_start_rung_reparam
.
back
(),
_phi_reparam
.
end
());
_scores
.
resize
(
_phi
.
size
());
#endif
#endif
start_time
=
omp_get_wtime
();
phi_sel
.
resize
(
cur_feat_local
);
scores_sel
.
resize
(
cur_feat_local
);
...
...
tests/googletest/utils/test_compare_features.cc
View file @
727dcd94
...
...
@@ -12,22 +12,26 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "gtest/gtest.h"
#include <utils/compare_features.hpp>
#include <feature_creation/node/ModelNode.hpp>
#include "feature_creation/node/ModelNode.hpp"
#include "mpi_interface/MPI_Ops.hpp"
#include "utils/compare_features.hpp"
namespace
{
//test mean calculations
TEST
(
CompFeats
,
CompFeatTest
)
{
std
::
vector
<
double
>
val_1
=
{
1.0
,
2.0
,
3.0
,
4.0
};
std
::
vector
<
double
>
val_2
=
{
2.0
,
2
.0
,
3.0
,
4.0
};
std
::
vector
<
double
>
val_2
=
{
2.0
,
1
.0
,
3.0
,
4.0
};
std
::
vector
<
double
>
val_3
=
{
2.0
,
4.0
,
6.0
,
8.0
};
std
::
vector
<
double
>
target
=
{
1.0
,
3.0
,
5.0
,
6.0
};
std
::
vector
<
double
>
scores
=
{
0.9897782665572893
};
std
::
vector
<
node_ptr
>
selected
(
1
);
std
::
vector
<
node_sc_pair
>
mpi_op_sel
(
1
);
node_value_arrs
::
initialize_values_arr
({
4
},
{
0
},
1
,
0
,
false
);
selected
[
0
]
=
std
::
make_shared
<
FeatureNode
>
(
0
,
"A"
,
val_3
,
std
::
vector
<
double
>
(),
Unit
());
mpi_op_sel
[
0
]
=
mpi_reduce_op
::
make_node_sc_pair
(
selected
[
0
],
scores
[
0
]);
node_value_arrs
::
initialize_d_matrix_arr
();
node_value_arrs
::
resize_d_matrix_arr
(
1
);
...
...
@@ -36,13 +40,36 @@ namespace {
EXPECT_FALSE
(
comp_feats
::
valid_feature_against_selected_pearson_max_corr_1
(
val_1
.
data
(),
4
,
1.0
,
scores
,
0.9897782665572893
,
1
,
0
));
EXPECT_FALSE
(
comp_feats
::
valid_feature_against_selected_pearson_max_corr_1_feat_list
(
val_1
.
data
(),
4
,
1.0
,
selected
,
scores
,
0.9897782665572893
));
EXPECT_FALSE
(
comp_feats
::
valid_feature_against_selected_pearson_max_corr_1_mpi_op
(
val_1
.
data
(),
4
,
1.0
,
mpi_op_sel
,
0.9897782665572893
));
EXPECT_FALSE
(
comp_feats
::
valid_feature_against_selected_pearson
(
val_1
.
data
(),
4
,
1.0
,
scores
,
0.9897782665572893
,
1
,
0
));
EXPECT_FALSE
(
comp_feats
::
valid_feature_against_selected_pearson_feat_list
(
val_1
.
data
(),
4
,
1.0
,
selected
,
scores
,
0.9897782665572893
));
EXPECT_FALSE
(
comp_feats
::
valid_feature_against_selected_pearson_mpi_op
(
val_1
.
data
(),
4
,
1.0
,
mpi_op_sel
,
0.9897782665572893
));
EXPECT_TRUE
(
comp_feats
::
valid_feature_against_selected_pearson_max_corr_1
(
val_2
.
data
(),
4
,
1.0
,
scores
,
0.9028289727756884
,
1
,
0
));
EXPECT_TRUE
(
comp_feats
::
valid_feature_against_selected_pearson_max_corr_1_feat_list
(
val_2
.
data
(),
4
,
1.0
,
selected
,
scores
,
0.9028289727756884
));
EXPECT_TRUE
(
comp_feats
::
valid_feature_against_selected_pearson_max_corr_1_mpi_op
(
val_2
.
data
(),
4
,
1.0
,
mpi_op_sel
,
0.9028289727756884
));
EXPECT_TRUE
(
comp_feats
::
valid_feature_against_selected_pearson
(
val_2
.
data
(),
4
,
1.0
,
scores
,
0.9028289727756884
,
1
,
0
));
EXPECT_TRUE
(
comp_feats
::
valid_feature_against_selected_pearson_feat_list
(
val_2
.
data
(),
4
,
1.0
,
selected
,
scores
,
0.9028289727756884
));
EXPECT_TRUE
(
comp_feats
::
valid_feature_against_selected_pearson_mpi_op
(
val_2
.
data
(),
4
,
1.0
,
mpi_op_sel
,
0.9028289727756884
));
EXPECT_FALSE
(
comp_feats
::
valid_feature_against_selected_spearman_max_corr_1
(
val_1
.
data
(),
4
,
1.0
,
scores
,
0.9897782665572893
,
1
,
0
));
EXPECT_FALSE
(
comp_feats
::
valid_feature_against_selected_spearman_max_corr_1_feat_list
(
val_1
.
data
(),
4
,
1.0
,
selected
,
scores
,
0.9897782665572893
));
EXPECT_FALSE
(
comp_feats
::
valid_feature_against_selected_spearman_max_corr_1_mpi_op
(
val_1
.
data
(),
4
,
1.0
,
mpi_op_sel
,
0.9897782665572893
));
EXPECT_FALSE
(
comp_feats
::
valid_feature_against_selected_spearman
(
val_1
.
data
(),
4
,
1.0
,
scores
,
0.9897782665572893
,
1
,
0
));
EXPECT_FALSE
(
comp_feats
::
valid_feature_against_selected_spearman_feat_list
(
val_1
.
data
(),
4
,
1.0
,
selected
,
scores
,
0.9897782665572893
));
EXPECT_FALSE
(
comp_feats
::
valid_feature_against_selected_spearman_mpi_op
(
val_1
.
data
(),
4
,
1.0
,
mpi_op_sel
,
0.9897782665572893
));
EXPECT_TRUE
(
comp_feats
::
valid_feature_against_selected_spearman_max_corr_1
(
val_2
.
data
(),
4
,
1.0
,
scores
,
0.9028289727756884
,
1
,
0
));
EXPECT_TRUE
(
comp_feats
::
valid_feature_against_selected_spearman_max_corr_1_feat_list
(
val_2
.
data
(),
4
,
1.0
,
selected
,
scores
,
0.9028289727756884
));
EXPECT_TRUE
(
comp_feats
::
valid_feature_against_selected_spearman_max_corr_1_mpi_op
(
val_2
.
data
(),
4
,
1.0
,
mpi_op_sel
,
0.9028289727756884
));
EXPECT_TRUE
(
comp_feats
::
valid_feature_against_selected_spearman
(
val_2
.
data
(),
4
,
1.0
,
scores
,
0.9028289727756884
,
1
,
0
));
EXPECT_TRUE
(
comp_feats
::
valid_feature_against_selected_spearman_feat_list
(
val_2
.
data
(),
4
,
1.0
,
selected
,
scores
,
0.9028289727756884
));
EXPECT_TRUE
(
comp_feats
::
valid_feature_against_selected_spearman_mpi_op
(
val_2
.
data
(),
4
,
1.0
,
mpi_op_sel
,
0.9028289727756884
));
node_value_arrs
::
finalize_values_arr
();
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment