Skip to content

Commit f119fb1

Browse files
committed
Build a list of bin counts based on available memory
1 parent 4535367 commit f119fb1

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

dpnp/tests/helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,4 +550,4 @@ def requires_memory(no_of_gbs, device=None):
550550
"""
551551

552552
free_mem = get_dev_info(device).get("free_memory", 0)
553-
return free_mem > no_of_gbs * (1024**3)
553+
return free_mem >= no_of_gbs * (1024**3)

dpnp/tests/test_histogram.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,14 @@
2222
get_integer_float_dtypes,
2323
has_support_aspect64,
2424
numpy_version,
25+
requires_memory,
2526
)
2627

28+
# Build a list of bin sizes to check the histogram
29+
_bin_counts = [10, 10**2, 10**3, 10**4, 10**5]
30+
if requires_memory(16):
31+
_bin_counts += [10**6]
32+
2733

2834
class TestDigitize:
2935
@pytest.mark.parametrize("dtype", get_integer_float_dtypes())
@@ -486,10 +492,7 @@ def test_weights_another_sycl_queue(self):
486492
with assert_raises(ValueError):
487493
dpnp.histogram(v, weights=w)
488494

489-
@pytest.mark.parametrize(
490-
"bins_count",
491-
[10, 10**2, 10**3, 10**4, 10**5, 10**6],
492-
)
495+
@pytest.mark.parametrize("bins_count", _bin_counts)
493496
def test_different_bins_amount(self, bins_count):
494497
v = numpy.linspace(0, bins_count, bins_count, dtype=numpy.float32)
495498
iv = dpnp.array(v)
@@ -584,10 +587,7 @@ def test_weights_unsupported_dtype(self, xp, dt):
584587
w = xp.arange(5, dtype=dt)
585588
assert_raises((TypeError, ValueError), xp.bincount, v, weights=w)
586589

587-
@pytest.mark.parametrize(
588-
"bins_count",
589-
[10, 10**2, 10**3, 10**4, 10**5, 10**6],
590-
)
590+
@pytest.mark.parametrize("bins_count", _bin_counts)
591591
def test_different_bins_amount(self, bins_count):
592592
v = numpy.arange(0, bins_count, dtype=int)
593593
iv = dpnp.array(v)
@@ -863,10 +863,7 @@ def test_weights_another_sycl_queue(self):
863863
with assert_raises(ValueError):
864864
dpnp.histogramdd(v, weights=w)
865865

866-
@pytest.mark.parametrize(
867-
"bins_count",
868-
[10, 10**2, 10**3, 10**4, 10**5, 10**6],
869-
)
866+
@pytest.mark.parametrize("bins_count", _bin_counts)
870867
def test_different_bins_amount(self, bins_count):
871868
v = numpy.linspace(0, bins_count, bins_count, dtype=numpy.float32)
872869
iv = dpnp.array(v)

0 commit comments

Comments
 (0)