From e728b11cd6e3cf1ac400f9a3c57c4ff7ce7cc5ee Mon Sep 17 00:00:00 2001 From: Frank Sauerburger <frank@sauerburger.com> Date: Fri, 4 Aug 2017 14:06:07 +0200 Subject: [PATCH] Use Agg backend for mpl in CI Add matplotlib.use('Agg') to the code examples, which is necessary when run in an environment without X11 sever, such as the CI pipeline. --- README.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b5d7612..1ce4347 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ Numpy arrays overload the typical arithmetic operations, such that the above statement benefits from numpys efficient, vectorized (i.e. performing the same operation on may values) implementation. You should always think about a way to use such vectorized statements, and try to avoid manually looping over all the -values. Using a python loop to run over 10^3 values is probably fine, but you +values. Using a python loop to run over $`10^3`$ values is probably fine, but you don't want to wait for a python loop iterating over 10^6 or 10^9 values. Finally add a print statement to check that all the caluclations are as expected. @@ -127,11 +127,19 @@ the cropped parabola f(x), which is limited y=4 for x>=2. ```math f(x) = \left\{\begin{array}{lr} x^2, & \text{for } x < 2\\ - 4, & \text{for } 2 \leq x\\ - \end{array}\right\} = xy + 4, & \text{for } 2 \leq x + \end{array}\right\. ``` Create the file `func_plot.py` and add the following lines. + +<!-- Add additional files for non-X11 environment in CI --> +<!-- write func_plot.py +```python +import matplotlib +matplotlib.use('Agg') +``` +--> <!-- write func_plot.py --> ```python import numpy as np -- GitLab