Skip to content

Commit

Permalink
simplify API
Browse files Browse the repository at this point in the history
  • Loading branch information
molpopgen committed Jul 6, 2024
1 parent 354de14 commit 234a90d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cpptests/test_site_dependent_genetic_value.cc
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ BOOST_FIXTURE_TEST_CASE(test_multiplicative_fitness_1, Fwdpy11Pop)
BOOST_REQUIRE(offspring_metadata[0].w > 0.0);

// we now pass in this correct lambda expression
m = fwdpy11::multiplicative_fitness_model(1, 2., nullptr, nullptr);
m = fwdpy11::multiplicative_fitness_model(1, 2., nullptr);
m(data);
BOOST_REQUIRE_EQUAL(offspring_metadata[0].g, 0.);
BOOST_REQUIRE_EQUAL(offspring_metadata[0].w, 0.);
Expand Down
20 changes: 20 additions & 0 deletions fwdpy11/headers/fwdpy11/genetic_values/DiploidAdditive.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <fwdpy11/types/Mutation.hpp>
#include <fwdpy11/genetic_value_to_fitness/GeneticValueIsTrait.hpp>
#include "fwdpp_wrappers/fwdpp_genetic_value.hpp"

namespace fwdpy11
Expand Down Expand Up @@ -73,4 +74,23 @@ namespace fwdpy11
single_deme_additive_het, single_deme_additive_hom, multi_deme_additive_het,
multi_deme_additive_hom, 0>;

inline DiploidAdditive
additive_fitness_model(std::size_t ndemes, double scaling,
const GeneticValueNoise* noise)
{
return DiploidAdditive(
ndemes, scaling, final_additive_fitness(),
[](const double) { return false; }, nullptr, noise);
}

inline DiploidAdditive
additive_trait_model(std::size_t ndemes, double scaling,
const GeneticValueIsTrait* gvalue_to_fitness,
const GeneticValueNoise* noise)
{
return DiploidAdditive(
ndemes, scaling, final_additive_trait(), [](const double) { return false; },
gvalue_to_fitness, noise);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,11 @@ namespace fwdpy11

inline DiploidMultiplicative
multiplicative_fitness_model(std::size_t ndemes, double scaling,
const GeneticValueIsTrait* gvalue_to_fitness,
const GeneticValueNoise* noise)
{
return DiploidMultiplicative(
ndemes, scaling, final_multiplicative_fitness(),
[](const double w) { return w <= 0.0; }, gvalue_to_fitness, noise);
[](const double w) { return w <= 0.0; }, nullptr, noise);
}

inline DiploidMultiplicative
Expand Down

0 comments on commit 234a90d

Please sign in to comment.