ExamplesΒΆ
Show code cell source
import math
import pathlib
import warnings
import demes
import demesdraw
import demesdraw.utils
import matplotlib.pyplot as plt
# Output SVG.
from matplotlib_inline.backend_inline import set_matplotlib_formats
set_matplotlib_formats("svg")
# Ignore warnings about simultaneous pulses in our examples.
warnings.filterwarnings("ignore", "Multiple pulses", UserWarning, "demes")
def plot_from_yaml(yaml_filename):
graph = demes.load(yaml_filename)
log_time = demesdraw.utils.log_time_heuristic(graph)
log_size = demesdraw.utils.log_size_heuristic(graph)
ax1 = demesdraw.size_history(
graph,
invert_x=True,
log_time=log_time,
log_size=log_size,
title=example.name,
)
ax2 = demesdraw.tubes(
graph,
log_time=log_time,
title=example.name,
)
plt.show(ax1.figure)
plt.show(ax2.figure)
plt.close(ax1.figure)
plt.close(ax2.figure)
print("\n\n")
# Plot each example yaml in the examples folder.
cwd = pathlib.Path(".").parent.resolve()
examples = list((cwd / ".." / "examples").glob("**/*.yaml"))
for example in sorted(examples):
plot_from_yaml(example)
/home/runner/work/demesdraw/demesdraw/demesdraw/utils.py:582: UserWarning: Failed to optimise: message: The maximum number of function evaluations is exceeded.
success: False
status: 0
fun: 267700252081.24774
x: [ 2.580e+04 2.580e+04 -1.061e+03 5.266e+04 -1.446e+05
-4.599e+04 1.513e+05]
nit: 1000
nfev: 1000
njev: 7223
nhev: 0
cg_niter: 3236
cg_stop_cond: 4
grad: [-1.379e-02 -1.095e-02 -2.638e+04 1.201e+06 -1.870e+06
-4.889e+05 1.184e+06]
lagrangian_grad: [-1.380e-02 -1.095e-02 -1.120e-02 -1.120e-02 -1.120e-02
-1.120e-02 -1.120e-02]
constr: [array([ 5.372e+04, 1.973e+05, 9.865e+04, 9.865e+04,
9.865e+04, 2.960e+05, 1.973e+05]), array([ 2.580e+04, 2.580e+04, -1.061e+03, 5.266e+04,
-1.446e+05, -4.599e+04, 1.513e+05])]
jac: [array([[ 0.000e+00, 0.000e+00, ..., 0.000e+00,
0.000e+00],
[ 0.000e+00, 0.000e+00, ..., 0.000e+00,
0.000e+00],
...,
[ 0.000e+00, 0.000e+00, ..., 0.000e+00,
1.000e+00],
[ 0.000e+00, 0.000e+00, ..., -1.000e+00,
1.000e+00]]), array([[ 1.000e+00, 0.000e+00, ..., 0.000e+00,
0.000e+00],
[ 0.000e+00, 1.000e+00, ..., 0.000e+00,
0.000e+00],
...,
[ 0.000e+00, 0.000e+00, ..., 1.000e+00,
0.000e+00],
[ 0.000e+00, 0.000e+00, ..., 0.000e+00,
1.000e+00]])]
constr_nfev: [0, 0]
constr_njev: [0, 0]
constr_nhev: [0, 0]
v: [array([-2.638e+04, -1.014e-06, -2.359e+06, -1.184e+06,
-1.870e+06, -5.068e-07, -1.014e-06]), array([-6.531e-07, -6.531e-07, -8.801e-07, -5.041e-07,
-8.073e-02, -1.763e-06, -2.146e-07])]
method: tr_interior_point
optimality: 0.013795645412239533
constr_violation: 45990.61737782677
execution_time: 3.144824504852295
tr_radius: 6039085.662223612
constr_penalty: 26333.43775024477
barrier_parameter: 0.1
barrier_tolerance: 0.1
niter: 1000
Please report this in the issue tracker at https://github.com/grahamgower/demesdraw/issues
warnings.warn(