mirror of
https://github.com/jupyter/docker-stacks.git
synced 2025-10-15 14:02:58 +00:00
add cm-super
This commit is contained in:
@@ -7,9 +7,9 @@ LABEL maintainer="Jupyter Project <jupyter@googlegroups.com>"
|
|||||||
|
|
||||||
USER root
|
USER root
|
||||||
|
|
||||||
# ffmpeg for matplotlib anim & dvipng for latex labels
|
# ffmpeg for matplotlib anim & dvipng+cm-super for latex labels
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
apt-get install -y --no-install-recommends ffmpeg dvipng && \
|
apt-get install -y --no-install-recommends ffmpeg dvipng cm-super && \
|
||||||
rm -rf /var/lib/apt/lists/*
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
USER $NB_UID
|
USER $NB_UID
|
||||||
|
20
scipy-notebook/test/data/matplotlib_fonts_1.py
Normal file
20
scipy-notebook/test/data/matplotlib_fonts_1.py
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
# Matplotlit: Test tex fonts
|
||||||
|
import matplotlib
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
import os
|
||||||
|
|
||||||
|
matplotlib.rcParams['pgf.texsystem'] = 'pdflatex'
|
||||||
|
matplotlib.rcParams.update({'font.family': 'serif', 'font.size': 18,
|
||||||
|
'axes.labelsize': 20, 'axes.titlesize': 24,
|
||||||
|
'figure.titlesize': 28})
|
||||||
|
matplotlib.rcParams['text.usetex'] = True
|
||||||
|
|
||||||
|
fig, ax = plt.subplots(1, 1)
|
||||||
|
x = [1, 2]
|
||||||
|
y = [1, 2]
|
||||||
|
ax.plot(x, y, label='a label')
|
||||||
|
ax.legend(fontsize=15)
|
||||||
|
|
||||||
|
file_path = os.path.join("/tmp", "test_fonts.png")
|
||||||
|
fig.savefig(file_path)
|
||||||
|
print(f"File {file_path} saved")
|
@@ -33,3 +33,30 @@ def test_matplotlib(container):
|
|||||||
cmd = running_container.exec_run(command)
|
cmd = running_container.exec_run(command)
|
||||||
assert cmd.exit_code == 0, f"Command {command} failed"
|
assert cmd.exit_code == 0, f"Command {command} failed"
|
||||||
LOGGER.debug(cmd.output.decode("utf-8"))
|
LOGGER.debug(cmd.output.decode("utf-8"))
|
||||||
|
|
||||||
|
|
||||||
|
def test_matplotlib_fonts(container):
|
||||||
|
"""Test matplotlib latex fonts, which depend on the cm-super package"""
|
||||||
|
host_data_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)),
|
||||||
|
"data")
|
||||||
|
cont_data_dir = "/home/jovyan/data"
|
||||||
|
test_file = "matplotlib_fonts_1.py"
|
||||||
|
output_dir = "/tmp"
|
||||||
|
LOGGER.info(f"Test cm-super latex labels in matplotlib ...")
|
||||||
|
command = "sleep infinity"
|
||||||
|
running_container = container.run(
|
||||||
|
volumes={host_data_dir: {"bind": cont_data_dir, "mode": "ro"}},
|
||||||
|
tty=True,
|
||||||
|
command=["start.sh", "bash", "-c", command],
|
||||||
|
)
|
||||||
|
command = f"python {cont_data_dir}/{test_file}"
|
||||||
|
cmd = running_container.exec_run(command)
|
||||||
|
assert cmd.exit_code == 0, f"Command {command} failed"
|
||||||
|
LOGGER.debug(cmd.output.decode("utf-8"))
|
||||||
|
# Checking if the file is generated
|
||||||
|
# https://stackoverflow.com/a/15895594/4413446
|
||||||
|
expected_file = f"{output_dir}/test_fonts.png"
|
||||||
|
command = f"test -s {expected_file}"
|
||||||
|
cmd = running_container.exec_run(command)
|
||||||
|
assert cmd.exit_code == 0, f"Command {command} failed"
|
||||||
|
LOGGER.debug(cmd.output.decode("utf-8"))
|
||||||
|
Reference in New Issue
Block a user