|
7 | 7 |
|
8 | 8 | from holoviews import Dataset, Dimension |
9 | 9 | from holoviews.core.data import NarwhalsInterface |
| 10 | +from holoviews.testing import assert_data_equal |
10 | 11 |
|
11 | 12 | from .base import HeterogeneousColumnTests, InterfaceTests |
12 | 13 |
|
@@ -317,3 +318,32 @@ def test_dataset_nodata_range(self): |
317 | 318 | msg = "cudf does not support mixed types, please type-cast the column of dataframe/series and other to same dtypes." |
318 | 319 | with pytest.raises(TypeError, match=re.escape(msg)): |
319 | 320 | 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