11"""conftest.py - pytest local plugins and fixtures"""
22
33import os
4- import sys
54from contextlib import contextmanager
65
76import matplotlib as mpl
87import numpy as np
98import pytest
10- import scipy as sp
119
1210import control
1311
@@ -45,15 +43,15 @@ def control_defaults():
4543 params = [pytest .param ("arrayout" , marks = matrixerrorfilter ),
4644 pytest .param ("matrixout" , marks = matrixfilter )])
4745def matarrayout (request ):
48- """Switch the config to use np.ndarray and np.matrix as returns"""
46+ """Switch the config to use np.ndarray and np.matrix as returns. """
4947 restore = control .config .defaults ['statesp.use_numpy_matrix' ]
5048 control .use_numpy_matrix (request .param == "matrixout" , warn = False )
5149 yield
5250 control .use_numpy_matrix (restore , warn = False )
5351
5452
5553def ismatarrayout (obj ):
56- """Test if the returned object has the correct type as configured
54+ """Test if the returned object has the correct type as configured.
5755
5856 note that isinstance(np.matrix(obj), np.ndarray) is True
5957 """
@@ -63,15 +61,15 @@ def ismatarrayout(obj):
6361
6462
6563def asmatarrayout (obj ):
66- """Return a object according to the configured default"""
64+ """Return a object according to the configured default. """
6765 use_matrix = control .config .defaults ['statesp.use_numpy_matrix' ]
6866 matarray = np .asmatrix if use_matrix else np .asarray
6967 return matarray (obj )
7068
7169
7270@contextmanager
7371def check_deprecated_matrix ():
74- """Check that a call produces a deprecation warning because of np.matrix"""
72+ """Check that a call produces a deprecation warning because of np.matrix. """
7573 use_matrix = control .config .defaults ['statesp.use_numpy_matrix' ]
7674 if use_matrix :
7775 with pytest .deprecated_call ():
@@ -94,19 +92,20 @@ def check_deprecated_matrix():
9492 False )]
9593 if usebydefault or TEST_MATRIX_AND_ARRAY ])
9694def matarrayin (request ):
97- """Use array and matrix to construct input data in tests"""
95+ """Use array and matrix to construct input data in tests. """
9896 return request .param
9997
10098
10199@pytest .fixture (scope = "function" )
102100def editsdefaults ():
103- """Make sure any changes to the defaults only last during a test"""
101+ """Make sure any changes to the defaults only last during a test. """
104102 restore = control .config .defaults .copy ()
105103 yield
106104 control .config .defaults = restore .copy ()
107105
108106
109107@pytest .fixture (scope = "function" )
108+ @pytest .mark .flaky (reruns = 2 , reruns_delay = 1 )
110109def mplcleanup ():
111110 """Clean up any plots and changes a test may have made to matplotlib.
112111
0 commit comments