Skip to content

Commit 3f69885

Browse files
committed
improve coverage test for pyfftw
1 parent 1de5370 commit 3f69885

File tree

3 files changed

+56
-23
lines changed

3 files changed

+56
-23
lines changed

stumpy/sdp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def _pocketfft_sliding_dot_product(Q, T):
108108
return c2r(False, np.multiply(fft_2d[0], fft_2d[1]), n=next_fast_n)[m - 1 : n]
109109

110110

111-
class _PYFFTW_SLIDING_DOT_PRODUCT: # pragma: no cover
111+
class _PYFFTW_SLIDING_DOT_PRODUCT:
112112
"""
113113
A class to compute the sliding dot product using FFTW via pyfftw.
114114

test.sh

Lines changed: 49 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -138,35 +138,68 @@ check_ray()
138138
fi
139139
}
140140

141+
init_coveragerc()
142+
{
143+
if [ ! -f .coveragerc_optional ]; then
144+
echo "[report]" > .coveragerc_optional
145+
echo "; Regexes for lines to exclude from consideration" >> .coveragerc_optional
146+
echo "exclude_also =" >> .coveragerc_optional
147+
fi
148+
}
149+
141150
gen_ray_coveragerc()
142151
{
143152
# Generate a .coveragerc_ray file that excludes Ray functions and tests
144-
echo "[report]" > .coveragerc_ray
145-
echo "; Regexes for lines to exclude from consideration" >> .coveragerc_ray
146-
echo "exclude_also =" >> .coveragerc_ray
147-
echo " def .*_ray_*" >> .coveragerc_ray
148-
echo " def ,*_ray\(*" >> .coveragerc_ray
149-
echo " def ray_.*" >> .coveragerc_ray
150-
echo " def test_.*_ray*" >> .coveragerc_ray
153+
# echo "[report]" > .coveragerc_ray
154+
init_coveragerc
155+
156+
echo " def .*_ray_*" >> .coveragerc_optional
157+
echo " def .*_ray\(*" >> .coveragerc_optional
158+
echo " def ray_.*" >> .coveragerc_optional
159+
echo " def test_.*_ray*" >> .coveragerc_optional
151160
}
152161

153-
set_ray_coveragerc()
162+
has_fftw_pyfftw()
154163
{
155-
# If `ray` command is not found then generate a .coveragerc_ray file
156-
if ! command -v ray &> /dev/null
157-
then
158-
echo "Ray Not Installed"
164+
command -v fftw-wisdom &> /dev/null \
165+
&& python -c "import pyfftw" &> /dev/null
166+
}
167+
168+
gen_pyfftw_coveragerc()
169+
{
170+
init_coveragerc
171+
echo " def .*_PYFFTW*" >> .coveragerc_optional
172+
echo " def .*_pyfftw*" >> .coveragerc_optional
173+
echo " def test_.*_pyfftw*" >> .coveragerc_optional
174+
}
175+
176+
177+
set_optional_coveragerc()
178+
{
179+
fcoveragerc=""
180+
181+
if ! command -v ray &> /dev/null; then
182+
echo "Ray not installed"
159183
gen_ray_coveragerc
160-
fcoveragerc="--rcfile=.coveragerc_ray"
161184
else
162-
echo "Ray Installed"
163-
fcoveragerc=""
185+
echo "Ray installed"
186+
fi
187+
188+
if ! has_fftw_pyfftw; then
189+
echo "pyFFTW / FFTW not available"
190+
gen_pyfftw_coveragerc
191+
else
192+
echo "pyFFTW available"
193+
fi
194+
195+
if [ -f .coveragerc_optional ]; then
196+
fcoveragerc="--rcfile=.coveragerc_optional"
164197
fi
165198
}
166199

167200
show_coverage_report()
168201
{
169-
set_ray_coveragerc
202+
set_optional_coveragerc
170203
coverage report --show-missing --fail-under=100 --skip-covered --omit=fastmath.py,docstring.py,versions.py $fcoveragerc
171204
check_errs $?
172205
}

tests/test_sdp.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ def test_sdp_power2():
182182
return
183183

184184

185-
def test_pyfftw_sdp_max_n(): # pragma: no cover
186-
if not PYFFTW_IMPORTED:
185+
def test_pyfftw_sdp_max_n():
186+
if not PYFFTW_IMPORTED: # pragma: no cover
187187
pytest.skip("Skipping Test PyFFTW Not Installed")
188188

189189
# When `len(T)` larger than `max_n` in pyfftw_sdp,
@@ -203,8 +203,8 @@ def test_pyfftw_sdp_max_n(): # pragma: no cover
203203
return
204204

205205

206-
def test_pyfftw_sdp_cache(): # pragma: no cover
207-
if not PYFFTW_IMPORTED:
206+
def test_pyfftw_sdp_cache():
207+
if not PYFFTW_IMPORTED: # pragma: no cover
208208
pytest.skip("Skipping Test PyFFTW Not Installed")
209209

210210
# To ensure that the caching mechanism in
@@ -228,8 +228,8 @@ def test_pyfftw_sdp_cache(): # pragma: no cover
228228
return
229229

230230

231-
def test_pyfftw_sdp_update_arrays(): # pragma: no cover
232-
if not PYFFTW_IMPORTED:
231+
def test_pyfftw_sdp_update_arrays():
232+
if not PYFFTW_IMPORTED: # pragma: no cover
233233
pytest.skip("Skipping Test PyFFTW Not Installed")
234234

235235
# To ensure that the cached FFTW objects

0 commit comments

Comments
 (0)