Skip to content

Commit

Permalink
More tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
vitenti committed Apr 13, 2024
1 parent 468b3df commit 583cf25
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 9 deletions.
17 changes: 8 additions & 9 deletions tests/test_nc_data_cluster_ncounts_gauss.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,23 +283,22 @@ test_nc_data_cluster_ncounts_gauss_mean_func (TestNcClusterNCountsGauss *test, g
void
test_nc_data_cluster_ncounts_gauss_cov (TestNcClusterNCountsGauss *test, gconstpointer pdata)
{
nc_data_cluster_ncounts_gauss_set_s_matrix (test->ncounts_gauss, test->s_matrix);
nc_data_cluster_ncounts_gauss_set_resample_s_matrix (test->ncounts_gauss, test->resample_s_matrix);

guint i;
guint j;
NcmDataGaussCov *gauss_cov = NCM_DATA_GAUSS_COV (test->ncounts_gauss);
NcmRNG *rng = ncm_rng_new (NULL);
NcmMatrix *cov_resample;
NcmMatrix *cov_diag;
NcmMatrix *cov_1;
NcmMatrix *cov_2;
NcmMatrix *cov_3;
NcmMatrix *cov_4;
NcmMatrix *cov_resample;
NcmDataGaussCov *gauss_cov = NCM_DATA_GAUSS_COV (test->ncounts_gauss);
NcmRNG *rng = ncm_rng_new (NULL);
guint i, j;

nc_data_cluster_ncounts_gauss_set_s_matrix (test->ncounts_gauss, test->s_matrix);
nc_data_cluster_ncounts_gauss_set_resample_s_matrix (test->ncounts_gauss, test->resample_s_matrix);

ncm_data_set_init (NCM_DATA (gauss_cov), TRUE);

g_assert_true (nc_data_cluster_ncounts_gauss_get_fix_cov (test->ncounts_gauss) == FALSE);
g_assert_false (nc_data_cluster_ncounts_gauss_get_fix_cov (test->ncounts_gauss));

cov_diag = ncm_matrix_dup (ncm_data_gauss_cov_compute_cov (gauss_cov, test->mset, NULL));
ncm_data_gauss_cov_set_cov (gauss_cov, cov_diag);
Expand Down
38 changes: 38 additions & 0 deletions tests/test_ncm_data_gauss_cov.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ void test_ncm_data_gauss_cov_test_resample (TestNcmDataGaussCovTest *test, gcons
void test_ncm_data_gauss_cov_test_bootstrap_resample (TestNcmDataGaussCovTest *test, gconstpointer pdata);
void test_ncm_data_gauss_cov_test_bootstrap_resample_norm (TestNcmDataGaussCovTest *test, gconstpointer pdata);
void test_ncm_data_gauss_cov_test_bulk_resample (TestNcmDataGaussCovTest *test, gconstpointer pdata);
void test_ncm_data_gauss_cov_compute_cov (TestNcmDataGaussCovTest *test, gconstpointer pdata);

void test_ncm_data_gauss_cov_mvnd_new (TestNcmDataGaussCovTest *test, gconstpointer pdata);
void test_ncm_data_gauss_cov_mvnd_free (TestNcmDataGaussCovTest *test, gconstpointer pdata);
Expand Down Expand Up @@ -85,6 +86,11 @@ main (gint argc, gchar *argv[])
&test_ncm_data_gauss_cov_test_bulk_resample,
&test_ncm_data_gauss_cov_test_free);

g_test_add ("/ncm/data_gauss_cov/test/compute_cov", TestNcmDataGaussCovTest, NULL,
&test_ncm_data_gauss_cov_test_new,
&test_ncm_data_gauss_cov_compute_cov,
&test_ncm_data_gauss_cov_test_free);

g_test_add ("/ncm/data_gauss_cov/mvnd/sanity", TestNcmDataGaussCovTest, NULL,
&test_ncm_data_gauss_cov_mvnd_new,
&test_ncm_data_gauss_cov_mvnd_sanity,
Expand Down Expand Up @@ -455,3 +461,35 @@ test_ncm_data_gauss_cov_test_bulk_resample (TestNcmDataGaussCovTest *test, gcons
ncm_vector_clear (&mean);
}

void
test_ncm_data_gauss_cov_compute_cov (TestNcmDataGaussCovTest *test, gconstpointer pdata)
{
NcmDataGaussCov *gauss = NCM_DATA_GAUSS_COV (test->data);
NcmMSet *mset = ncm_mset_empty_new ();
NcmMatrix *cov;

cov = ncm_data_gauss_cov_compute_cov (gauss, mset, NULL);

g_assert_true (NCM_IS_MATRIX (cov));
g_assert_true (ncm_matrix_nrows (cov) == ncm_data_gauss_cov_get_size (gauss));
g_assert_true (ncm_matrix_ncols (cov) == ncm_data_gauss_cov_get_size (gauss));

ncm_matrix_free (cov);

{
gboolean updated = FALSE;

cov = ncm_data_gauss_cov_compute_cov (gauss, mset, &updated);

g_assert_true (updated);

g_assert_true (NCM_IS_MATRIX (cov));
g_assert_true (ncm_matrix_nrows (cov) == ncm_data_gauss_cov_get_size (gauss));
g_assert_true (ncm_matrix_ncols (cov) == ncm_data_gauss_cov_get_size (gauss));

ncm_matrix_free (cov);
}

ncm_mset_clear (&mset);
}

0 comments on commit 583cf25

Please sign in to comment.