Skip to content

Commit

Permalink
import of new C++ type works
Browse files Browse the repository at this point in the history
  • Loading branch information
molpopgen committed Aug 18, 2023
1 parent 4c80e57 commit 51c5aec
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 1 deletion.
1 change: 1 addition & 0 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ set(GENETIC_VALUE_TO_FITNESS_SOURCES
genetic_value_to_fitness/GeneticValueIsFitness.cc
genetic_value_to_fitness/GeneticValueIsTrait.cc
genetic_value_to_fitness/GSSmo.cc
genetic_value_to_fitness/GaussianStabilizingSelection.cc
genetic_value_to_fitness/MultivariateGSSmo.cc
genetic_value_to_fitness/Optimum.cc
genetic_value_to_fitness/PleiotropicOptima.cc)
Expand Down
19 changes: 19 additions & 0 deletions cpp/genetic_value_to_fitness/GaussianStabilizingSelection.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <tuple>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <fwdpy11/genetic_value_to_fitness/GaussianStabilizingSelection.hpp>

namespace py = pybind11;

void
init_GaussianStabilizingSelection(py::module& m)
{
py::class_<fwdpy11::GaussianStabilizingSelection, fwdpy11::GeneticValueIsTrait>(
m, "_ll_GaussianStabilizingSelection")
.def(py::init([](const fwdpy11::GSSmo& single_trait) {
return fwdpy11::GaussianStabilizingSelection(single_trait);
}))
.def(py::init([](const fwdpy11::MultivariateGSSmo& pleiotropy) {
return fwdpy11::GaussianStabilizingSelection(pleiotropy);
}));
}
2 changes: 2 additions & 0 deletions cpp/genetic_value_to_fitness/init.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ void init_GeneticValueToFitnessMap(py::module&);
void init_GeneticValueIsTrait(py::module&);
void init_GeneticValueIsFitness(py::module&);
void init_GSSmo(py::module&);
void init_GaussianStabilizingSelection(py::module&);

// Multivariate classes
void init_MultivariateGSSmo(py::module&);
Expand All @@ -25,6 +26,7 @@ initialize_genetic_value_to_fitness(py::module& m)
init_GeneticValueIsTrait(m);
init_GeneticValueIsFitness(m);
init_GSSmo(m);
init_GaussianStabilizingSelection(m);

init_MultivariateGSSmo(m);
}
1 change: 1 addition & 0 deletions fwdpy11/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
from .genetic_values import ( # NOQA
PleiotropicOptima,
Optimum,
GaussianStabilizingSelection,
GSS,
GSSmo,
MultivariateGSS,
Expand Down
4 changes: 3 additions & 1 deletion fwdpy11/genetic_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
import numpy as np

from ._fwdpy11 import (GeneticValueIsTrait, GeneticValueNoise, _ll_Additive,
_ll_GaussianNoise, _ll_GBR, _ll_GSSmo,
_ll_GaussianNoise, _ll_GBR,
_ll_GaussianStabilizingSelection,
_ll_GSSmo,
_ll_Multiplicative, _ll_MultivariateGSSmo, _ll_NoNoise,
_ll_Optimum, _ll_PleiotropicOptima,
_ll_StrictAdditiveMultivariateEffects)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,17 @@ namespace fwdpy11
{
}

double
operator()(const DiploidGeneticValueToFitnessData data) const final {
return this->pimpl->operator()(data);
}

void
update(const DiploidPopulation &pop) final
{
return this->pimpl->update(pop);
}

std::shared_ptr<GeneticValueToFitnessMap>
clone() const final
{
Expand Down

0 comments on commit 51c5aec

Please sign in to comment.