Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge dev #1187

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/docker_deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
pull_request:
branches:
- 'main'
- 'dev'

jobs:
docker:
Expand Down
44 changes: 24 additions & 20 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ jobs:
strategy:
matrix:
python: [ 3.8, 3.9, "3.10", "3.11" ]
os: [ ubuntu-20.04 ]
compiler: [gcc, clang10]
os: [ ubuntu-22.04 ]
compiler: [gcc, clang14]
rust: [1.62.1]
defaults:
run:
Expand Down Expand Up @@ -55,19 +55,32 @@ jobs:
run: |
echo "$HOME/.local/bin" >> $GITHUB_PATH

- name: Set GCC as compiler
if: matrix.compiler == 'gcc'
run: |
echo "CC=gcc" >> $GITHUB_ENV
echo "CXX=g++" >> $GITHUB_ENV

- name: Install clang-14
if: matrix.compiler == 'clang14'
run: |
sudo apt-get install clang-14 clang++-14
echo "CC=clang-14" >> $GITHUB_ENV
echo "CXX=clang++-14" >> $GITHUB_ENV

- name: Discover llvm-config
run: |
dpkg -S llvm-config

- name: Set LLVM_CONFIG on 20.04
if: matrix.os == 'ubuntu-20.04'
- name: Set LLVM_CONFIG on 22.04
if: matrix.os == 'ubuntu-22.04'
run: |
echo "LLVM_CONFIG=/usr/bin/llvm-config-10" >> $GITHUB_ENV
echo "LLVM_CONFIG=/usr/bin/llvm-config" >> $GITHUB_ENV

- name: Set LLVM_CONFIG on 18.04
if: matrix.os == 'ubuntu-18.04'
run: |
echo "LLVM_CONFIG=/usr/lib/llvm-9/bin/llvm-config" >> $GITHUB_ENV
# - name: Set LLVM_CONFIG on 18.04
# if: matrix.os == 'ubuntu-18.04'
# run: |
# echo "LLVM_CONFIG=/usr/lib/llvm-9/bin/llvm-config" >> $GITHUB_ENV

- name: Python version
run: |
Expand All @@ -91,20 +104,11 @@ jobs:
# For sdist validation
python -m pip install --user --upgrade twine

- name: Set GCC as compiler
if: matrix.compiler == 'gcc'
# Needed so that we don't affect building any pip dependencies with these flags
- name: Set CPPFLAGS for C++ builds
run: |
echo "CC=gcc" >> $GITHUB_ENV
echo "CXX=g++" >> $GITHUB_ENV
echo "CPPFLAGS=-Wextra -Weffc++ -Woverloaded-virtual -Wold-style-cast -Werror=effc++ -Werror=old-style-cast -Werror=overloaded-virtual -Werror=unused-parameter" >> $GITHUB_ENV

- name: Install clang-10
if: matrix.compiler == 'clang10'
run: |
sudo apt-get install clang-10 clang++-10
echo "CC=clang-10" >> $GITHUB_ENV
echo "CXX=clang++-10" >> $GITHUB_ENV

- name: Build
run: |
cmake -E env CPPFLAGS="$CPPFLAGS" \
Expand Down
13 changes: 9 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
cmake_minimum_required(VERSION 3.15)
# Do not change this version range!
# Doing so can break builds in unexpected ways.
# The manylinux wheel build seem especially sensitive!
cmake_minimum_required(VERSION 3.4...3.18)
project(fwdpy11)

set(CMAKE_CXX_EXTENSIONS OFF)
Expand All @@ -13,10 +16,12 @@ if (APPLE)
set(CMAKE_MACOSX_RPATH 1)
endif()

find_package(pybind11)
find_package(Python COMPONENTS Interpreter Development)
find_package(pybind11 CONFIG)

message(STATUS "Found pybind11: ${pybind11_VERSION}")
if(${pybind11_VERSION} VERSION_LESS '2.10.0')
message(FATAL_ERROR "pybind11 version must be >= '2.10.0'")
if(${pybind11_VERSION} VERSION_LESS '2.11.1')
message(FATAL_ERROR "pybind11 version must be >= '2.11.1'")
endif()
add_definitions(-DPYBIND11_VERSION="${pybind11_VERSION}")

Expand Down
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);
}
2 changes: 1 addition & 1 deletion deployment/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ WORKDIR /app

COPY . /app

RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -qq -y install cmake \
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -qq -y install \
gcc \
git \
g++ \
Expand Down
6 changes: 3 additions & 3 deletions doc/long_vignettes/gss_vignette.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Recorder(object):
```

Now, we will set up and simulate the model.
We use {class}`fwdpy11.GSSmo` to specify when/how the optimum value shifts.
We use {class}`fwdpy11.GaussianStabilizingSelection` to specify when/how the optimum value shifts.

We will simulate the population for $10N$ generations around an optimum of zero.
Then, we shift the optimum to 1 and evolve another 200 generations.
Expand All @@ -51,7 +51,7 @@ pop = fwdpy11.DiploidPopulation(500, 1.0)

rng = fwdpy11.GSLrng(54321)

GSSmo = fwdpy11.GSSmo(
gssmo = fwdpy11.GaussianStabilizingSelection.single_trait(
[
fwdpy11.Optimum(when=0, optimum=0.0, VS=1.0),
fwdpy11.Optimum(when=10 * pop.N - 200, optimum=1.0, VS=1.0),
Expand All @@ -62,7 +62,7 @@ rho = 1000.

p = {
"nregions": [],
"gvalue": fwdpy11.Additive(2.0, GSSmo),
"gvalue": fwdpy11.Additive(2.0, gssmo),
"sregions": [fwdpy11.GaussianS(0, 1., 1, 0.1)],
"recregions": [fwdpy11.PoissonInterval(0, 1., rho / float(4 * pop.N))],
"rates": (0.0, 1e-3, None),
Expand Down
14 changes: 9 additions & 5 deletions doc/long_vignettes/tskitconvert_vignette.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,13 @@ assert "model_params" not in ts.metadata
Here is an example of Gaussian stabilizing selection around an optimum trait value of `0.0`:

```{code-cell} python
optimum = fwdpy11.Optimum(optimum=0.0, VS=10.0, when=0)
gss = fwdpy11.GaussianStabilizingSelection.single_trait([optimum])
pdict = {
'nregions': [],
'sregions': [fwdpy11.GaussianS(0, 1, 1, 0.10)],
'recregions': [fwdpy11.PoissonInterval(0, 1, 1e-3)],
'gvalue': fwdpy11.Additive(2., fwdpy11.GSS(optimum=0.0, VS=10.0)),
'gvalue': fwdpy11.Additive(2., gss),
'rates': (0.0, 1e-3, None),
'simlen': 10 * pop.N,
'prune_selected': False,
Expand All @@ -165,16 +167,18 @@ Imagine, for example, that we simulate the above model until equilibrium, and th
The details are omitted here:

1. This simulation requires two calls to {func}`fwdpy11.evolvets`
2. It could have been done instead with a single call to {func}`fwdpy11.evolvets` and using
{class}`fwdpy11.GSSmo` and one `ModelParams` object instead of {class}`fwdpy11.GSS`
and two parameters objects.
2. It could have been done instead with a single call to {func}`fwdpy11.evolvets`
by passing a list of {class}`fwdpy11.Optimum` to {class}`fwdpy11.GaussianStabilizingSelection`.
This approach would have required one `ModelParams` instance.
:::

```{code-cell} python
import copy
pdict2 = copy.deepcopy(pdict)

pdict2['gvalue'] = fwdpy11.Additive(2., fwdpy11.GSS(optimum=5.0, VS=10.0)),
optimum = fwdpy11.Optimum(optimum=5.0, VS=10.0, when=0)
gss = fwdpy11.GaussianStabilizingSelection.single_trait([optimum])
pdict2['gvalue'] = fwdpy11.Additive(2., gss),
pdict2['simlen'] = 100

params2 = fwdpy11.ModelParams(**pdict2)
Expand Down
24 changes: 20 additions & 4 deletions doc/misc/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
Major changes are listed below. Each release likely contains fiddling with back-end code,
updates to latest `fwdpp` version, etc.

## Next release

Deprecations

The following are deprecated:

* `fwdpy11.GSS`
* `fwdpy11.GSSmo`
* `fwdpy11.MutivariateGSS`
* `fwdpy11.MutivariateGSSmo`

Their functionality is replaced with {class}`fwdpy11.GaussianStabilizingSelection`.

PR {pr}`1166`.
Issue {issue}{`463`}.

## 0.21.0

Breaking changes
Expand Down Expand Up @@ -643,12 +659,12 @@ Changes to `fwdpy11.conditional_models`:

Bug fixes

* Fixed bug in updating {class}`fwdpy11.MultivariateGSSmo`.
* Fixed bug in updating `fwdpy11.MultivariateGSSmo`.
PR {pr}`867`.

Back end changes:

* {class}`fwdpy11.GSSmo` and {class}`fwdpy11.MultivariateGSSmo` now handle cases where population start time is greater than zero.
* `fwdpy11.GSSmo` and `fwdpy11.MultivariateGSSmo` now handle cases where population start time is greater than zero.
PR {pr}`867`.

Build system:
Expand Down Expand Up @@ -1260,7 +1276,7 @@ Maintenance release and one new feature:

* Allow the first generation of a simulation to be preserved. PR {pr}`470`
See {ref}`recapitation`.
* Parameterizing classes like {class}`fwdpy11.GSSmo` is now more Pythonic,
* Parameterizing classes like `fwdpy11.GSSmo` is now more Pythonic,
and some existing `init` methods are deprecated in favor of the
new approach. PR {pr}`461`.

Expand Down Expand Up @@ -1479,7 +1495,7 @@ Miscellaneous changes:
The following bugs are fixed:

* Mutations were not being recycled properly during simulations with tree sequences, resulting in excessive memory consumption. PR {pr}`317`
* Several interface issues with {class}`fwdpy11.MultivariateGSSmo` are fixed. PR {pr}`313`
* Several interface issues with `fwdpy11.MultivariateGSSmo` are fixed. PR {pr}`313`
* Fix a bug that could lead to fixations with tree sequences not "pruning" selected fixations when that behavior is desired. {issue}`287`, fixed in PR {pr}`289`
* A memory safety issue was fixed in the implementation of {attr}`fwdpy11.TreeIterator.samples_below`. PR {pr}`300`. {issue}`299`

Expand Down
3 changes: 2 additions & 1 deletion doc/pages/advancedtopics.md
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,8 @@ class MyGeneticValueToFitness(fwdpy11.GeneticValueIsTrait):
```

Two complete examples come from the test suite. The first example reimplements
{class}`fwdpy11.GSS` in Python. The second example implements a model
{class}`fwdpy11.GaussianStabilizingSelection` in Python for a single trait.
The second example implements a model
where the optimum changes to a new value each generation. (Note that
the second model requires that {func}`numpy.random.seed` be called elsewhere
so that results are reproducible.)
Expand Down
18 changes: 2 additions & 16 deletions doc/pages/gvalue_to_fitness.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,6 @@
.. autoclass:: fwdpy11.GeneticValueIsFitness
```

```{eval-rst}
.. autoclass:: fwdpy11.GSS
:members: asdict, fromdict, asblack
```

```{eval-rst}
.. autoclass:: fwdpy11.GSSmo
:members: asdict, fromdict, asblack
```

```{eval-rst}
.. autoclass:: fwdpy11.Optimum
:members: asdict, fromdict, asblack
Expand All @@ -33,14 +23,10 @@
:members: asdict, fromdict, asblack
```

```{eval-rst}
.. autoclass:: fwdpy11.MultivariateGSS
:members: asdict, fromdict, asblack
```

```{eval-rst}
.. autoclass:: fwdpy11.MultivariateGSSmo
:members: asdict, fromdict, asblack
.. autoclass:: fwdpy11.GaussianStabilizingSelection
:members:
```


2 changes: 1 addition & 1 deletion doc/short_vignettes/evolvets_vignette.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pop = fwdpy11.DiploidPopulation(500, 1.0)

rng = fwdpy11.GSLrng(54321)

GSSmo = fwdpy11.GSSmo(
GSSmo = fwdpy11.GaussianStabilizingSelection.single_trait(
[
fwdpy11.Optimum(when=0, optimum=0.0, VS=1.0),
fwdpy11.Optimum(when=10 * pop.N - 200, optimum=1.0, VS=1.0),
Expand Down
Loading