Test whether prediction is correct.
(self)
| 13 | |
| 14 | class TestLoadPickle: |
| 15 | def test_load_pkl(self) -> None: |
| 16 | """Test whether prediction is correct.""" |
| 17 | assert os.environ["CUDA_VISIBLE_DEVICES"] == "-1" |
| 18 | bst = load_pickle(model_path) |
| 19 | x, y = build_dataset() |
| 20 | if isinstance(bst, xgb.Booster): |
| 21 | test_x = xgb.DMatrix(x) |
| 22 | res = bst.predict(test_x) |
| 23 | else: |
| 24 | res = bst.predict(x) |
| 25 | assert len(res) == 10 |
| 26 | bst.set_params(n_jobs=1) # triggers a re-configuration |
| 27 | res = bst.predict(x) |
| 28 | |
| 29 | assert len(res) == 10 |
| 30 | |
| 31 | def test_context_is_removed(self) -> None: |
| 32 | """Under invalid CUDA_VISIBLE_DEVICES, context should reset""" |
nothing calls this directly
no test coverage detected