Skip to content

Commit

Permalink
* Updated stubs.
Browse files Browse the repository at this point in the history
* More tests for test_py_powspec_spline2d.py.
* Removed interface for eval_unit from CSQ1D.
  • Loading branch information
vitenti committed Mar 22, 2024
1 parent 5f207cb commit e1b41a4
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 79 deletions.
17 changes: 0 additions & 17 deletions numcosmo/math/ncm_csq1d.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,6 @@ static gdouble _ncm_csq1d_eval_int_q2mnu2 (NcmCSQ1D *csq1d, NcmModel *model, con
static gdouble _ncm_csq1d_eval_F1 (NcmCSQ1D *csq1d, NcmModel *model, const gdouble t);
static gdouble _ncm_csq1d_eval_F2 (NcmCSQ1D *csq1d, NcmModel *model, const gdouble t);
static gdouble _ncm_csq1d_eval_FN (NcmCSQ1D *csq1d, NcmModel *model, const gint n, const gdouble t);
static gdouble _ncm_csq1d_eval_unit (NcmCSQ1D *csq1d, NcmModel *model);

static void
ncm_csq1d_class_init (NcmCSQ1DClass *klass)
Expand Down Expand Up @@ -515,7 +514,6 @@ ncm_csq1d_class_init (NcmCSQ1DClass *klass)
klass->eval_F1 = &_ncm_csq1d_eval_F1;
klass->eval_F2 = &_ncm_csq1d_eval_F2;
klass->eval_FN = &_ncm_csq1d_eval_FN;
klass->eval_unit = &_ncm_csq1d_eval_unit;
}

static gdouble
Expand Down Expand Up @@ -617,14 +615,6 @@ _ncm_csq1d_eval_FN (NcmCSQ1D *csq1d, NcmModel *model, const gint n, const gdoubl
return 0.0;
}

static gdouble
_ncm_csq1d_eval_unit (NcmCSQ1D *csq1d, NcmModel *model)
{
g_error ("_ncm_csq1d_eval_unit: not implemented.");

return 0.0;
}

/* State related functions */

/**
Expand Down Expand Up @@ -1733,13 +1723,6 @@ _ncm_csq1d_J_Um (realtype t, N_Vector y, N_Vector fy, SUNMatrix J, gpointer jac_
*
* Returns: $F_n$
*/
/**
* ncm_csq1d_eval_unit: (virtual eval_unit)
* @csq1d: a #NcmCSQ1D
* @model: (allow-none): a #NcmModel
*
* Returns: $F_n$
*/

static NcmCSQ1DEvolStop
_ncm_csq1d_evol_adiabatic (NcmCSQ1D *csq1d, NcmModel *model, GArray *asinh_t_a, GArray *alpha_a, GArray *dgamma_a, GArray *gamma_a)
Expand Down
8 changes: 0 additions & 8 deletions numcosmo/math/ncm_csq1d.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ struct _NcmCSQ1DClass
gdouble (*eval_F1) (NcmCSQ1D *csq1d, NcmModel *model, const gdouble t);
gdouble (*eval_F2) (NcmCSQ1D *csq1d, NcmModel *model, const gdouble t);
gdouble (*eval_FN) (NcmCSQ1D *csq1d, NcmModel *model, const gint n, const gdouble t);
gdouble (*eval_unit) (NcmCSQ1D *csq1d, NcmModel *model);
void (*prepare) (NcmCSQ1D *csq1d, NcmModel *model);

/* Padding to allow 18 virtual functions without breaking ABI. */
Expand Down Expand Up @@ -188,7 +187,6 @@ NCM_INLINE gdouble ncm_csq1d_eval_dm (NcmCSQ1D *csq1d, NcmModel *model,
NCM_INLINE gdouble ncm_csq1d_eval_F1 (NcmCSQ1D *csq1d, NcmModel *model, const gdouble t);
NCM_INLINE gdouble ncm_csq1d_eval_F2 (NcmCSQ1D *csq1d, NcmModel *model, const gdouble t);
NCM_INLINE gdouble ncm_csq1d_eval_FN (NcmCSQ1D *csq1d, NcmModel *model, const gint n, const gdouble t);
NCM_INLINE gdouble ncm_csq1d_eval_unit (NcmCSQ1D *csq1d, NcmModel *model);

void ncm_csq1d_prepare (NcmCSQ1D *csq1d, NcmModel *model);

Expand Down Expand Up @@ -289,12 +287,6 @@ ncm_csq1d_eval_FN (NcmCSQ1D *csq1d, NcmModel *model, const gint n, const gdouble
return NCM_CSQ1D_GET_CLASS (csq1d)->eval_FN (csq1d, model, n, t);

Check warning on line 287 in numcosmo/math/ncm_csq1d.h

View check run for this annotation

Codecov / codecov/patch

numcosmo/math/ncm_csq1d.h#L287

Added line #L287 was not covered by tests
}

NCM_INLINE gdouble
ncm_csq1d_eval_unit (NcmCSQ1D *csq1d, NcmModel *model)
{
return NCM_CSQ1D_GET_CLASS (csq1d)->eval_unit (csq1d, model);
}

G_END_DECLS

#endif /* __GTK_DOC_IGNORE__ */
Expand Down
21 changes: 5 additions & 16 deletions numcosmo/perturbations/nc_hipert_adiab.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ static gdouble _nc_hipert_adiab_eval_xi (NcmCSQ1D *csq1d, NcmModel *model, const
static gdouble _nc_hipert_adiab_eval_F1 (NcmCSQ1D *csq1d, NcmModel *model, const gdouble t);
static gdouble _nc_hipert_adiab_eval_nu (NcmCSQ1D *csq1d, NcmModel *model, const gdouble t);
static gdouble _nc_hipert_adiab_eval_m (NcmCSQ1D *csq1d, NcmModel *model, const gdouble t);
static gdouble _nc_hipert_adiab_eval_unit (NcmCSQ1D *csq1d, NcmModel *model);

static void _nc_hipert_adiab_prepare (NcmCSQ1D *csq1d, NcmModel *model);

Expand All @@ -197,12 +196,11 @@ nc_hipert_adiab_class_init (NcHIPertAdiabClass *klass)
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_NAME | G_PARAM_STATIC_BLURB));


csq1d_class->eval_xi = &_nc_hipert_adiab_eval_xi;
csq1d_class->eval_F1 = &_nc_hipert_adiab_eval_F1;
csq1d_class->eval_nu = &_nc_hipert_adiab_eval_nu;
csq1d_class->eval_m = &_nc_hipert_adiab_eval_m;
csq1d_class->prepare = &_nc_hipert_adiab_prepare;
csq1d_class->eval_unit = &_nc_hipert_adiab_eval_unit;
csq1d_class->eval_xi = &_nc_hipert_adiab_eval_xi;
csq1d_class->eval_F1 = &_nc_hipert_adiab_eval_F1;
csq1d_class->eval_nu = &_nc_hipert_adiab_eval_nu;
csq1d_class->eval_m = &_nc_hipert_adiab_eval_m;
csq1d_class->prepare = &_nc_hipert_adiab_prepare;
}

static gdouble
Expand Down Expand Up @@ -247,15 +245,6 @@ _nc_hipert_adiab_prepare (NcmCSQ1D *csq1d, NcmModel *model)
g_assert (NC_IS_HIPERT_IADIAB (model));

Check warning on line 245 in numcosmo/perturbations/nc_hipert_adiab.c

View check run for this annotation

Codecov / codecov/patch

numcosmo/perturbations/nc_hipert_adiab.c#L245

Added line #L245 was not covered by tests
}

static gdouble
_nc_hipert_adiab_eval_unit (NcmCSQ1D *csq1d, NcmModel *model)
{
NcHIPertAdiab *pa = NC_HIPERT_ADIAB (csq1d);
const gdouble k = pa->k;

return nc_hipert_iadiab_eval_unit (NC_HIPERT_IADIAB (model));
}

/**
* nc_hipert_iadiab_eval_xi:
* @iad: a #NcHIPertIAdiab
Expand Down
25 changes: 6 additions & 19 deletions numcosmo/perturbations/nc_hipert_em.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,6 @@ static gdouble _nc_hipert_em_eval_xi (NcmCSQ1D *csq1d, NcmModel *model, const gd
static gdouble _nc_hipert_em_eval_F1 (NcmCSQ1D *csq1d, NcmModel *model, const gdouble t);
static gdouble _nc_hipert_em_eval_nu (NcmCSQ1D *csq1d, NcmModel *model, const gdouble t);
static gdouble _nc_hipert_em_eval_m (NcmCSQ1D *csq1d, NcmModel *model, const gdouble t);

static gdouble _nc_hipert_em_eval_unit (NcmCSQ1D *csq1d, NcmModel *model);

static void _nc_hipert_em_prepare (NcmCSQ1D *csq1d, NcmModel *model);

static void
Expand All @@ -167,12 +164,11 @@ nc_hipert_em_class_init (NcHIPertEMClass *klass)
0.0, G_MAXDOUBLE, 1.0,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_NAME | G_PARAM_STATIC_BLURB));

csq1d_class->eval_xi = &_nc_hipert_em_eval_xi;
csq1d_class->eval_F1 = &_nc_hipert_em_eval_F1;
csq1d_class->eval_nu = &_nc_hipert_em_eval_nu;
csq1d_class->eval_m = &_nc_hipert_em_eval_m;
csq1d_class->prepare = &_nc_hipert_em_prepare;
csq1d_class->eval_unit = &_nc_hipert_em_eval_unit;
csq1d_class->eval_xi = &_nc_hipert_em_eval_xi;
csq1d_class->eval_F1 = &_nc_hipert_em_eval_F1;
csq1d_class->eval_nu = &_nc_hipert_em_eval_nu;
csq1d_class->eval_m = &_nc_hipert_em_eval_m;
csq1d_class->prepare = &_nc_hipert_em_prepare;
}

static gdouble
Expand Down Expand Up @@ -217,15 +213,6 @@ _nc_hipert_em_prepare (NcmCSQ1D *csq1d, NcmModel *model)
g_assert (NC_IS_HIPERT_IEM (model));
}

Check warning on line 214 in numcosmo/perturbations/nc_hipert_em.c

View check run for this annotation

Codecov / codecov/patch

numcosmo/perturbations/nc_hipert_em.c#L213-L214

Added lines #L213 - L214 were not covered by tests

static gdouble
_nc_hipert_em_eval_unit (NcmCSQ1D *csq1d, NcmModel *model)
{
NcHIPertEM *pem = NC_HIPERT_EM (csq1d);
const gdouble k = pem->k;

return nc_hipert_iem_eval_unit (NC_HIPERT_IEM (model));
}

/**
* nc_hipert_iem_eval_xi:
* @iem: a #NcHIPertIEM
Expand Down Expand Up @@ -436,7 +423,7 @@ nc_hipert_em_eval_PE_PB (NcHIPertEM *pem, NcmModel *model, const gdouble tau, gd
{
NcmCSQ1D *csq1d = NCM_CSQ1D (pem);
NcHIPertIEM *iem = NC_HIPERT_IEM (model);
const gdouble unit = ncm_csq1d_eval_unit (csq1d, model);
const gdouble unit = nc_hipert_iem_eval_unit (iem);
const gdouble m = ncm_csq1d_eval_m (csq1d, model, tau);
const gdouble k = pem->k;
const gdouble x = nc_hipert_iem_eval_x (iem, tau);
Expand Down
21 changes: 5 additions & 16 deletions numcosmo/perturbations/nc_hipert_gw.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ static gdouble _nc_hipert_gw_eval_xi (NcmCSQ1D *csq1d, NcmModel *model, const gd
static gdouble _nc_hipert_gw_eval_F1 (NcmCSQ1D *csq1d, NcmModel *model, const gdouble t);
static gdouble _nc_hipert_gw_eval_nu (NcmCSQ1D *csq1d, NcmModel *model, const gdouble t);
static gdouble _nc_hipert_gw_eval_m (NcmCSQ1D *csq1d, NcmModel *model, const gdouble t);
static gdouble _nc_hipert_gw_eval_unit (NcmCSQ1D *csq1d, NcmModel *model);
static void _nc_hipert_gw_prepare (NcmCSQ1D *csq1d, NcmModel *model);

static void
Expand All @@ -165,12 +164,11 @@ nc_hipert_gw_class_init (NcHIPertGWClass *klass)
0.0, G_MAXDOUBLE, 1.0,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_NAME | G_PARAM_STATIC_BLURB));

csq1d_class->eval_xi = &_nc_hipert_gw_eval_xi;
csq1d_class->eval_F1 = &_nc_hipert_gw_eval_F1;
csq1d_class->eval_nu = &_nc_hipert_gw_eval_nu;
csq1d_class->eval_m = &_nc_hipert_gw_eval_m;
csq1d_class->prepare = &_nc_hipert_gw_prepare;
csq1d_class->eval_unit = &_nc_hipert_gw_eval_unit;
csq1d_class->eval_xi = &_nc_hipert_gw_eval_xi;
csq1d_class->eval_F1 = &_nc_hipert_gw_eval_F1;
csq1d_class->eval_nu = &_nc_hipert_gw_eval_nu;
csq1d_class->eval_m = &_nc_hipert_gw_eval_m;
csq1d_class->prepare = &_nc_hipert_gw_prepare;
}

static gdouble
Expand Down Expand Up @@ -215,15 +213,6 @@ _nc_hipert_gw_prepare (NcmCSQ1D *csq1d, NcmModel *model)
g_assert (NC_IS_HIPERT_IGW (model));

Check warning on line 213 in numcosmo/perturbations/nc_hipert_gw.c

View check run for this annotation

Codecov / codecov/patch

numcosmo/perturbations/nc_hipert_gw.c#L213

Added line #L213 was not covered by tests
}

static gdouble
_nc_hipert_gw_eval_unit (NcmCSQ1D *csq1d, NcmModel *model)
{
NcHIPertGW *pgw = NC_HIPERT_GW (csq1d);
const gdouble k = pgw->k;

return nc_hipert_igw_eval_unit (NC_HIPERT_IGW (model));
}

/**
* nc_hipert_igw_eval_xi:
* @igw: a #NcHIPertIGW
Expand Down
3 changes: 0 additions & 3 deletions numcosmo_py/ncm.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1149,7 +1149,6 @@ class CSQ1D(GObject.Object):
def do_eval_m(self, model: Optional[Model], t: float) -> float: ...
def do_eval_nu(self, model: Optional[Model], t: float) -> float: ...
def do_eval_nu2(self, model: Optional[Model], t: float) -> float: ...
def do_eval_unit(self, model: Optional[Model] = None) -> float: ...
def do_eval_xi(self, model: Optional[Model], t: float) -> float: ...
def do_prepare(self, model: Optional[Model] = None) -> None: ...
def eval_F1(self, model: Optional[Model], t: float) -> float: ...
Expand All @@ -1167,7 +1166,6 @@ class CSQ1D(GObject.Object):
def eval_m(self, model: Optional[Model], t: float) -> float: ...
def eval_nu(self, model: Optional[Model], t: float) -> float: ...
def eval_nu2(self, model: Optional[Model], t: float) -> float: ...
def eval_unit(self, model: Optional[Model] = None) -> float: ...
def eval_xi(self, model: Optional[Model], t: float) -> float: ...
def evolve_prop_vector(
self,
Expand Down Expand Up @@ -1235,7 +1233,6 @@ class CSQ1DClass(GObject.GPointer):
eval_F1: Callable[[CSQ1D, Optional[Model], float], float] = ...
eval_F2: Callable[[CSQ1D, Optional[Model], float], float] = ...
eval_FN: Callable[[CSQ1D, Optional[Model], int, float], float] = ...
eval_unit: Callable[[CSQ1D, Optional[Model]], float] = ...
prepare: Callable[[CSQ1D, Optional[Model]], None] = ...
padding: list[None] = ...

Expand Down
17 changes: 17 additions & 0 deletions tests/test_py_powspec_spline2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,23 @@ def _evec(z):
assert_allclose(ps_Pka, fa)


def test_get_spline2d(Pk2d: Ncm.Spline2d) -> None:
"""Test the getter of the power spectrum."""
ps = Ncm.PowspecSpline2d.new(Pk2d)

assert ps is not None

s2d = ps.peek_spline2d()

assert s2d is not None
assert s2d == Pk2d

sd2 = ps.get_spline_2d()

assert sd2 is not None
assert sd2 == Pk2d


def test_serialization(Pk2d: Ncm.Spline2d) -> None:
"""Test the serialization of the power spectrum."""

Expand Down

0 comments on commit e1b41a4

Please sign in to comment.