Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_gpu_stump_self_join(T_A, T_B):
m = 3
zone = int(np.ceil(m / 4))
left = np.array(
[
naive_mass(Q, T_B, m, i, zone, True)
for i, Q in enumerate(core.rolling_window(T_B, m))
],
dtype=object,
)
right = gpu_stump(T_B, m, ignore_trivial=True, threads_per_block=THREADS_PER_BLOCK)
replace_inf(left)
replace_inf(right)
npt.assert_almost_equal(left, right)
right = gpu_stump(
pd.Series(T_B), m, ignore_trivial=True, threads_per_block=THREADS_PER_BLOCK
)
replace_inf(right)
npt.assert_almost_equal(left, right)
for i, Q in enumerate(core.rolling_window(T_B, m))
],
dtype=object,
)
right = gpu_stump(
T_B,
m,
ignore_trivial=True,
threads_per_block=THREADS_PER_BLOCK,
device_id=device_ids,
)
replace_inf(left)
replace_inf(right)
npt.assert_almost_equal(left, right)
right = gpu_stump(
pd.Series(T_B),
m,
ignore_trivial=True,
threads_per_block=THREADS_PER_BLOCK,
device_id=device_ids,
)
replace_inf(right)
npt.assert_almost_equal(left, right)
def test_gpu_stump_self_join(T_A, T_B):
m = 3
zone = int(np.ceil(m / 4))
left = np.array(
[
naive_mass(Q, T_B, m, i, zone, True)
for i, Q in enumerate(core.rolling_window(T_B, m))
],
dtype=object,
)
right = gpu_stump(T_B, m, ignore_trivial=True, threads_per_block=THREADS_PER_BLOCK)
replace_inf(left)
replace_inf(right)
npt.assert_almost_equal(left, right)
right = gpu_stump(
pd.Series(T_B), m, ignore_trivial=True, threads_per_block=THREADS_PER_BLOCK
)
replace_inf(right)
npt.assert_almost_equal(left, right)
left = np.array(
[naive_mass(Q, T_A, m) for Q in core.rolling_window(T_B, m)], dtype=object
)
right = gpu_stump(
T_A,
m,
T_B,
ignore_trivial=False,
threads_per_block=THREADS_PER_BLOCK,
device_id=device_ids,
)
replace_inf(left)
replace_inf(right)
npt.assert_almost_equal(left, right)
right = gpu_stump(
pd.Series(T_A),
m,
pd.Series(T_B),
ignore_trivial=False,
threads_per_block=THREADS_PER_BLOCK,
device_id=device_ids,
)
replace_inf(right)
npt.assert_almost_equal(left, right)
def test_parallel_gpu_stump_self_join(T_A, T_B):
device_ids = [device.id for device in cuda.list_devices()]
if len(T_B) > 10:
m = 3
zone = int(np.ceil(m / 4))
left = np.array(
[
naive_mass(Q, T_B, m, i, zone, True)
for i, Q in enumerate(core.rolling_window(T_B, m))
],
dtype=object,
)
right = gpu_stump(
T_B,
m,
ignore_trivial=True,
threads_per_block=THREADS_PER_BLOCK,
device_id=device_ids,
)
replace_inf(left)
replace_inf(right)
npt.assert_almost_equal(left, right)
right = gpu_stump(
pd.Series(T_B),
m,
ignore_trivial=True,
threads_per_block=THREADS_PER_BLOCK,
device_id=device_ids,
left = np.array(
[
naive_mass(Q, T_B, m, i, zone, True)
for i, Q in enumerate(core.rolling_window(T_B, m))
],
dtype=object,
)
right = gpu_stump(
T_B, m, ignore_trivial=True, threads_per_block=THREADS_PER_BLOCK
)
replace_inf(left)
replace_inf(right)
npt.assert_almost_equal(left, right)
right = gpu_stump(
pd.Series(T_B),
m,
ignore_trivial=True,
threads_per_block=THREADS_PER_BLOCK,
)
replace_inf(right)
npt.assert_almost_equal(left, right)
def test_parallel_gpu_stump_A_B_join(T_A, T_B):
device_ids = [device.id for device in cuda.list_devices()]
if len(T_B) > 10:
m = 3
left = np.array(
[naive_mass(Q, T_A, m) for Q in core.rolling_window(T_B, m)], dtype=object
)
right = gpu_stump(
T_A,
m,
T_B,
ignore_trivial=False,
threads_per_block=THREADS_PER_BLOCK,
device_id=device_ids,
)
replace_inf(left)
replace_inf(right)
npt.assert_almost_equal(left, right)
right = gpu_stump(
pd.Series(T_A),
m,
pd.Series(T_B),
ignore_trivial=False,
def test_gpu_stump_A_B_join(T_A, T_B):
m = 3
left = np.array(
[naive_mass(Q, T_A, m) for Q in core.rolling_window(T_B, m)], dtype=object
)
right = gpu_stump(
T_A, m, T_B, ignore_trivial=False, threads_per_block=THREADS_PER_BLOCK
)
replace_inf(left)
replace_inf(right)
npt.assert_almost_equal(left, right)
right = gpu_stump(
pd.Series(T_A),
m,
pd.Series(T_B),
ignore_trivial=False,
threads_per_block=THREADS_PER_BLOCK,
)
replace_inf(right)
npt.assert_almost_equal(left, right)
def test_gpu_stump_self_join_larger_window(T_A, T_B):
for m in [8, 16, 32]:
if len(T_B) > m:
zone = int(np.ceil(m / 4))
left = np.array(
[
naive_mass(Q, T_B, m, i, zone, True)
for i, Q in enumerate(core.rolling_window(T_B, m))
],
dtype=object,
)
right = gpu_stump(
T_B, m, ignore_trivial=True, threads_per_block=THREADS_PER_BLOCK
)
replace_inf(left)
replace_inf(right)
npt.assert_almost_equal(left, right)
right = gpu_stump(
pd.Series(T_B),
m,
ignore_trivial=True,
threads_per_block=THREADS_PER_BLOCK,
)
replace_inf(right)
npt.assert_almost_equal(left, right)
def test_gpu_stump_A_B_join(T_A, T_B):
m = 3
left = np.array(
[naive_mass(Q, T_A, m) for Q in core.rolling_window(T_B, m)], dtype=object
)
right = gpu_stump(
T_A, m, T_B, ignore_trivial=False, threads_per_block=THREADS_PER_BLOCK
)
replace_inf(left)
replace_inf(right)
npt.assert_almost_equal(left, right)
right = gpu_stump(
pd.Series(T_A),
m,
pd.Series(T_B),
ignore_trivial=False,
threads_per_block=THREADS_PER_BLOCK,
)
replace_inf(right)
npt.assert_almost_equal(left, right)