1717// along with fwdpy11. If not, see <http://www.gnu.org/licenses/>.
1818//
1919#include < pybind11/pybind11.h>
20- #include < fwdpy11/genetic_values/DiploidGeneticValue .hpp>
20+ #include < fwdpy11/genetic_values/DiploidGeneticValueCalculation .hpp>
2121#include < fwdpy11/genetic_value_to_fitness/GeneticValueIsTrait.hpp>
2222#include < fwdpp/fitness_models.hpp>
2323
@@ -43,13 +43,10 @@ struct PyDiploidGeneticValueData
4343 }
4444};
4545
46- class PyDiploidGeneticValue : public fwdpy11 ::DiploidGeneticValue
46+ class PyDiploidGeneticValue : public fwdpy11 ::DiploidGeneticValueCalculation
4747{
4848 public:
49- PyDiploidGeneticValue (std::size_t ndim,
50- const fwdpy11::GeneticValueToFitnessMap* gvalue_to_fitness_map,
51- const fwdpy11::GeneticValueNoise* noise)
52- : fwdpy11::DiploidGeneticValue(ndim, gvalue_to_fitness_map, noise)
49+ PyDiploidGeneticValue () : fwdpy11::DiploidGeneticValueCalculation()
5350 {
5451 }
5552};
@@ -63,30 +60,13 @@ class PyDiploidGeneticValueTrampoline : public PyDiploidGeneticValue
6360 calculate_gvalue (const fwdpy11::DiploidGeneticValueData input_data) override
6461 {
6562 PYBIND11_OVERLOAD_PURE (double , PyDiploidGeneticValue, calculate_gvalue,
66- PyDiploidGeneticValueData (input_data, this ->gvalues ));
67- }
68-
69- double
70- genetic_value_to_fitness (
71- const fwdpy11::DiploidGeneticValueToFitnessData input_data) override
72- // NOTE: see https://pybind11.readthedocs.io/en/stable/advanced/classes.html#extended-trampoline-class-functionality
73- {
74- pybind11::gil_scoped_acquire gil; // Acquire the GIL while in this scope.
75- // Try to look up the overloaded method on the Python side.
76- pybind11::function overload
77- = pybind11::get_overload (this , " genetic_value_to_fitness" );
78- if (overload)
79- {
80- auto obj = overload (input_data);
81- return obj.cast <double >();
82- }
83- return this ->gv2w ->operator ()(input_data);
63+ PyDiploidGeneticValueData (input_data));
8464 }
8565
8666 void
8767 update (const fwdpy11::DiploidPopulation& pop) override
8868 {
89- PYBIND11_OVERLOAD_PURE (void , PyDiploidGeneticValue , update, pop);
69+ PYBIND11_OVERLOAD_PURE (void , PyDiploidGeneticValueCalculation , update, pop);
9070 }
9171};
9272
@@ -118,12 +98,9 @@ additive_effects(const fwdpy11::DiploidPopulation& pop,
11898void
11999init_PyDiploidGeneticValue (py::module & m)
120100{
121- py::class_<PyDiploidGeneticValue, fwdpy11::DiploidGeneticValue,
122- PyDiploidGeneticValueTrampoline>(m, " _PyDiploidGeneticValue" )
123- .def (py::init<std::size_t , const fwdpy11::GeneticValueToFitnessMap*,
124- const fwdpy11::GeneticValueNoise*>(),
125- py::arg (" ndim" ), py::arg (" genetic_value_to_fitness" ),
126- py::arg (" noise" ));
101+ py::class_<PyDiploidGeneticValue, fwdpy11::DiploidGeneticValueCalculation,
102+ PyDiploidGeneticValueTrampoline>(m, " _PyDiploidGeneticValueCalculation" )
103+ .def (py::init<>());
127104
128105 py::class_<PyDiploidGeneticValueData>(m, " PyDiploidGeneticValueData" ,
129106 py::buffer_protocol ())
0 commit comments