Skip to content

Commit 46e1647

Browse files
committed
Update gpu test
1 parent 13c8905 commit 46e1647

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

holoviews/tests/core/data/test_narwhalsinterface.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
from holoviews import Dataset, Dimension
99
from holoviews.core.data import NarwhalsInterface
10+
from holoviews.testing import assert_data_equal
1011

1112
from .base import HeterogeneousColumnTests, InterfaceTests
1213

@@ -317,3 +318,32 @@ def test_dataset_nodata_range(self):
317318
msg = "cudf does not support mixed types, please type-cast the column of dataframe/series and other to same dtypes."
318319
with pytest.raises(TypeError, match=re.escape(msg)):
319320
return super().test_dataset_nodata_range()
321+
322+
def test_dataset_sample_hm(self):
323+
samples = self.dataset_hm.sample([0, 5, 10]).dimension_values('y')
324+
assert samples.implementation == nw.Implementation.CUDF
325+
assert_data_equal(np.array([0, 10, 20]), samples.to_numpy())
326+
327+
def test_dataset_sample_hm_alias(self):
328+
samples = self.dataset_hm_alias.sample([0, 5, 10]).dimension_values('y')
329+
assert samples.implementation == nw.Implementation.CUDF
330+
assert_data_equal(np.array([0, 10, 20]), samples.to_numpy())
331+
332+
def test_dataset_add_dimensions_value_hm(self):
333+
table = self.dataset_hm.add_dimension('z', 1, 0)
334+
assert table.kdims[1] == 'z'
335+
data = table.dimension_values('z')
336+
assert data.implementation == nw.Implementation.CUDF
337+
assert_data_equal(np.zeros(table.shape[0]), data.to_numpy())
338+
339+
def test_dataset_add_dimensions_values_hm(self):
340+
table = self.dataset_hm.add_dimension('z', 1, range(1,12))
341+
assert table.kdims[1] == 'z'
342+
data = table.dimension_values('z')
343+
assert data.implementation == nw.Implementation.CUDF
344+
assert_data_equal(np.array(list(range(1,12))), data.to_numpy())
345+
346+
def test_dataset_sample_ht(self):
347+
samples = self.dataset_ht.sample([0, 5, 10]).dimension_values('y')
348+
assert samples.implementation == nw.Implementation.CUDF
349+
assert_data_equal(np.array([0, 0.5, 1]), samples.to_numpy())

0 commit comments

Comments
 (0)