()
| 216 | |
| 217 | |
| 218 | def test_data_cache() -> None: |
| 219 | n_batches = 1 |
| 220 | n_features = 2 |
| 221 | n_samples_per_batch = 16 |
| 222 | data = make_batches(n_samples_per_batch, n_features, n_batches, False) |
| 223 | batches = [v[0] for v in data] |
| 224 | |
| 225 | # Test with a cache. |
| 226 | it = IterForCacheTest(batches[0], batches[1], batches[2], release_data=False) |
| 227 | transform = xgb.data._proxy_transform |
| 228 | |
| 229 | called = 0 |
| 230 | |
| 231 | def mock(*args: Any, **kwargs: Any) -> Any: |
| 232 | nonlocal called |
| 233 | called += 1 |
| 234 | return transform(*args, **kwargs) |
| 235 | |
| 236 | xgb.data._proxy_transform = mock |
| 237 | xgb.QuantileDMatrix(it) |
| 238 | assert it._data_ref is weakref.ref(batches[0]) |
| 239 | assert called == 1 |
| 240 | |
| 241 | # Test without a cache. |
| 242 | called = 0 |
| 243 | it = IterForCacheTest(batches[0], batches[1], batches[2], release_data=True) |
| 244 | xgb.QuantileDMatrix(it) |
| 245 | assert called == 4 |
| 246 | |
| 247 | xgb.data._proxy_transform = transform |
| 248 | |
| 249 | |
| 250 | def test_cat_check(tmp_path: Path) -> None: |
nothing calls this directly
no test coverage detected