MCPcopy Create free account
hub / github.com/dmlc/xgboost / test_data_cache

Function test_data_cache

tests/python/test_data_iterator.py:218–247  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

216
217
218def 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
250def test_cat_check(tmp_path: Path) -> None:

Callers

nothing calls this directly

Calls 4

make_batchesFunction · 0.90
IterForCacheTestClass · 0.85
QuantileDMatrixMethod · 0.80
refMethod · 0.80

Tested by

no test coverage detected