Skip to content

Commit

Permalink
fix(plotting): Use Agg backend only during testing with pytest (#415)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkrako authored May 17, 2023
1 parent bb8060c commit a02c9e6
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/pymovements/plotting/traceplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
"""
from __future__ import annotations

import sys

import matplotlib
import matplotlib.pyplot as plt
import numpy as np
Expand All @@ -30,8 +32,11 @@

from pymovements.gaze.gaze_dataframe import GazeDataFrame


matplotlib.use('Agg')
# This is really a dirty workaround to use the Agg backend if runnning pytest.
# This is needed as Windows workers on GitHub fail randomly with other backends.
# Unfortunately the Agg module cannot show plots in jupyter notebooks.
if 'pytest' in sys.modules: # pragma: no cover
matplotlib.use('Agg')

DEFAULT_SEGMENTDATA = {
'red': [
Expand Down Expand Up @@ -79,7 +84,7 @@ def traceplot(
gaze: GazeDataFrame,
x: str,
y: str,
cval: np.ndarray | None = None,
cval: np.ndarray | None = None, # pragma: no cover
cmap: colors.Colormap | None = None,
cmap_norm: colors.Normalize | str | None = None,
cmap_segmentdata: dict[str, list[list[float]]] | None = None,
Expand Down

0 comments on commit a02c9e6

Please sign in to comment.