Skip to content
Merged
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
5 changes: 5 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ jobs:
python-version: ${{ matrix.python-version }}
allow-prereleases: true

- name: Install LaTeX
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends texlive texlive-latex-extra cm-super lmodern dvipng

- name: Install dependencies
env:
BEZIER_IGNORE_VERSION_CHECK: "1"
Expand Down
Binary file modified docs/assets/plots/ck_test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/assets/plots/contacts.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/assets/plots/dendrogram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/assets/plots/macrotraj.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/assets/plots/sankey.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/assets/plots/state_network.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/assets/plots/timescales_kl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/assets/plots/timescales_t.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/assets/plots/transition_matrix.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/assets/plots/transition_time.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/MPP/graph/kinetic_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from .._style import FONT_FAMILY

pplt.use_style(figsize=1.8, figratio=1)
plt.rcParams["text.usetex"] = True
plt.rcParams["font.family"] = [FONT_FAMILY]

USE_FA2 = True
Expand Down
18 changes: 8 additions & 10 deletions src/MPP/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@


def _apply_style(**kwargs):
"""Call pplt.use_style and enforce the package font family."""
"""Call pplt.use_style and enforce LaTeX rendering with the package font family."""
pplt.use_style(**kwargs)
plt.rcParams["text.usetex"] = True
plt.rcParams["font.family"] = [FONT_FAMILY]


Expand Down Expand Up @@ -255,9 +256,7 @@ def implied_timescales(
if first_ref:
ref_trajectory = trajectories.pop(0)
x, y = utils.get_grid_format(len(trajectories))
_apply_style(
figsize=(2.7 * scale, 2.7 * scale), latex=False, colors="pastel_autumn"
)
_apply_style(figsize=(2.7 * scale, 2.7 * scale), colors="pastel_autumn")
fig, axs = plt.subplots(y, x, sharex=True, sharey=True)
plt.grid(False)
if not isinstance(axs, np.ndarray):
Expand Down Expand Up @@ -381,7 +380,7 @@ def relative_implied_timescales(cl, out):
out : str
Path to save the output figure.
"""
_apply_style(figsize=(8, 2.5), latex=False, colors="pastel_autumn")
_apply_style(figsize=(8, 2.5), colors="pastel_autumn")

ref = cl.reference
its = cl.timescales / ref.timescales
Expand Down Expand Up @@ -838,7 +837,6 @@ def contact_rep(contacts, cluster_file, state_trajectory, output, grid, scale=1)
figsize=1.2 * scale,
colors="pastel_autumn",
true_black=True,
latex=False,
)

# load files
Expand Down Expand Up @@ -912,7 +910,7 @@ def contact_rep(contacts, cluster_file, state_trajectory, output, grid, scale=1)
pplt.text(
0.5,
0.95,
rf"S{state + 1} {pop_state:.1%}",
rf"S{state + 1} {100 * pop_state:.1f}\%",
ha="center",
va="top",
ax=ax,
Expand Down Expand Up @@ -1066,7 +1064,6 @@ def rmsd(rmsds, pops, helices=None, filename=None):
figsize=(w, h),
colors="pastel_autumn",
true_black=True,
latex=False,
)
fig, axs = plt.subplots(
n_plots,
Expand Down Expand Up @@ -1259,7 +1256,6 @@ def delta_rmsd(rmsds, pops, helices=None, filename=None):
figsize=(w, h),
colors="pastel_autumn",
true_black=True,
latex=False,
)
fig, axs = plt.subplots(
n_plots,
Expand Down Expand Up @@ -1443,6 +1439,9 @@ def state_trajectory(trajectory, filename, row_length=0.2, frame_length=0.2):
Duration of each frame in ns. Used to scale the x-axis label in μs.
(default 0.2)
"""
plt.rcParams["text.usetex"] = True
plt.rcParams["font.family"] = [FONT_FAMILY]

if row_length > 1:
x_max = int(row_length)
elif row_length > 0:
Expand Down Expand Up @@ -1570,7 +1569,6 @@ def chapman_kolmogorov(mpt, out, frame_length=0.2):
figsize=4.8,
colors="pastel_autumn",
true_black=True,
latex=False,
)

nrows, ncols = utils.get_grid_format(mpt.n_macrostates[mpt.run_index])
Expand Down
Binary file modified tests/data/HP35/baseline/js/macrostate_assignment.npy
Binary file not shown.
Binary file modified tests/data/HP35/baseline/kl/Z.npy
Binary file not shown.
Binary file modified tests/data/HP35/baseline/kl/macrostate_assignment.npy
Binary file not shown.
Binary file modified tests/data/HP35/baseline/t/Z.npy
Binary file not shown.
Binary file modified tests/data/HP35/baseline/t/macrostate_assignment.npy
Binary file not shown.
Binary file modified tests/data/HP35/baseline/t_js/macrostate_assignment.npy
Binary file not shown.
Binary file modified tests/data/HP35/expected_output/gpcca/Z.npy
Binary file not shown.
Binary file modified tests/data/PDZ3/baseline/kl/Z.npy
Binary file not shown.
Binary file modified tests/data/aSyn/baseline/kl_js/macrostate_assignment.npy
Binary file not shown.
Binary file modified tests/data/aSyn/baseline/t/Z.npy
Binary file not shown.
Binary file modified tests/data/aSyn/baseline/t/macrostate_assignment.npy
Binary file not shown.
19 changes: 13 additions & 6 deletions tests/test_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,15 @@ def _assert_font_family(self, dataset, kind, d, g, stochastic=False):
/ f"Z{'_stochastic' if stochastic else ''}.npy"
)

observed_fonts = []
observed = []

original_savefig = matplotlib.figure.Figure.savefig

def capturing_savefig(fig_self, fname, *args, **kwargs):
observed_fonts.append(list(plt.rcParams.get("font.family", [])))
observed.append({
"usetex": plt.rcParams.get("text.usetex"),
"font.family": list(plt.rcParams.get("font.family", [])),
})
return original_savefig(fig_self, fname, *args, **kwargs)

with tempfile.TemporaryDirectory() as tmpdir:
Expand All @@ -276,14 +279,18 @@ def capturing_savefig(fig_self, fname, *args, **kwargs):
_run_main_with_args(args)

self.assertTrue(
len(observed_fonts) > 0,
len(observed) > 0,
f"savefig was never called for plot kind '{kind}'",
)
for fonts in observed_fonts:
for snapshot in observed:
self.assertTrue(
snapshot["usetex"],
f"text.usetex is not True for plot kind '{kind}': {snapshot}",
)
self.assertIn(
FONT_FAMILY,
fonts,
f"Font family '{FONT_FAMILY}' not found in {fonts} for plot kind '{kind}'",
snapshot["font.family"],
f"Font family '{FONT_FAMILY}' not set for plot kind '{kind}': {snapshot}",
)

def test_font_dendrogram(self):
Expand Down
Loading