Skip to content

Commit

Permalink
TST: Mark threading test as slow
Browse files Browse the repository at this point in the history
  • Loading branch information
andfoy committed May 6, 2024
1 parent cae61d0 commit 54b6390
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
18 changes: 14 additions & 4 deletions scipy/interpolate/tests/test_interpnd.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
import os
import sys

import numpy as np
from numpy.testing import (assert_equal, assert_allclose, assert_almost_equal,
suppress_warnings)
from pytest import raises as assert_raises
import pytest

from scipy._lib._testutils import check_free_memory
import scipy.interpolate.interpnd as interpnd
import scipy.spatial._qhull as qhull

import pickle
import threading

_IS_32BIT = (sys.maxsize < 2**32)


def data_file(basename):
return os.path.join(os.path.abspath(os.path.dirname(__file__)),
Expand Down Expand Up @@ -167,7 +171,13 @@ def test_pickle(self):

assert_almost_equal(ip(0.5, 0.5), ip2(0.5, 0.5))

@pytest.mark.slow
@pytest.mark.skipif(_IS_32BIT, reason='it fails on 32-bit')
def test_threading(self):
# This test was taken from issue 8856
# https://github.com/scipy/scipy/issues/8856
check_free_memory(30000)

r_ticks = np.arange(0, 500, 10)
phi_ticks = np.arange(0, 500, 10)
r_grid, phi_grid = np.meshgrid(r_ticks, phi_ticks)
Expand All @@ -183,16 +193,16 @@ def do_interp(interpolator, slice_rows, slice_cols):

worker_thread_1 = threading.Thread(
target=do_interp,
args=(interpolator, slice(0, 2500), slice(0, 2500)))
args=(interpolator, slice(0, 250), slice(0, 250)))
worker_thread_2 = threading.Thread(
target=do_interp,
args=(interpolator, slice(2500, 5000), slice(0, 2500)))
args=(interpolator, slice(250, 500), slice(0, 250)))
worker_thread_3 = threading.Thread(
target=do_interp,
args=(interpolator, slice(0, 2500), slice(2500, 5000)))
args=(interpolator, slice(0, 250), slice(250, 500)))
worker_thread_4 = threading.Thread(
target=do_interp,
args=(interpolator, slice(2500, 5000), slice(2500, 5000)))
args=(interpolator, slice(250, 500), slice(250, 500)))

worker_thread_1.start()
worker_thread_2.start()
Expand Down
4 changes: 3 additions & 1 deletion scipy/spatial/_qhull.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ Wrappers for Qhull triangulation, plus some additional N-D geometry utilities
import numpy as np
cimport numpy as np
cimport cython
from cpython.pythread cimport (PyThread_type_lock, PyThread_allocate_lock, PyThread_free_lock, PyThread_acquire_lock, PyThread_release_lock)
from cpython.pythread cimport (
PyThread_type_lock, PyThread_allocate_lock, PyThread_free_lock,
PyThread_acquire_lock, PyThread_release_lock)

from . cimport _qhull
from . cimport setlist
Expand Down

0 comments on commit 54b6390

Please sign in to comment.