|
17 | 17 | from lenskit import util
|
18 | 18 | from lenskit.algorithms import als
|
19 | 19 |
|
20 |
| -try: |
21 |
| - import binpickle |
22 |
| -except ImportError: |
23 |
| - binpickle = None |
24 |
| - |
25 | 20 | _log = logging.getLogger(__name__)
|
26 | 21 |
|
27 | 22 | simple_df = pd.DataFrame(
|
@@ -248,39 +243,6 @@ def test_als_save_load():
|
248 | 243 | assert len(preds) == 50
|
249 | 244 |
|
250 | 245 |
|
251 |
| -@mark.skipif(not binpickle, reason="binpickle not available") |
252 |
| -def test_als_binpickle(tmp_path): |
253 |
| - "Test saving ALS with BinPickle" |
254 |
| - |
255 |
| - original = als.BiasedMF(20, iterations=5) |
256 |
| - ratings = lktu.ml_test.ratings |
257 |
| - original.fit(ratings) |
258 |
| - |
259 |
| - assert original.bias.mean_ == approx(ratings.rating.mean()) |
260 |
| - |
261 |
| - file = tmp_path / "als.bpk" |
262 |
| - binpickle.dump(original, file) |
263 |
| - |
264 |
| - with binpickle.BinPickleFile(file) as bpf: |
265 |
| - # the pickle data should be small |
266 |
| - _log.info("serialized to %d pickle bytes", bpf.entries[-1].dec_length) |
267 |
| - assert bpf.entries[-1].dec_length < 2048 |
268 |
| - |
269 |
| - algo = bpf.load() |
270 |
| - |
271 |
| - assert algo.bias.mean_ == original.bias.mean_ |
272 |
| - assert np.all(algo.bias.user_offsets_ == original.bias.user_offsets_) |
273 |
| - assert np.all(algo.bias.item_offsets_ == original.bias.item_offsets_) |
274 |
| - assert np.all(algo.user_features_ == original.user_features_) |
275 |
| - assert np.all(algo.item_features_ == original.item_features_) |
276 |
| - assert np.all(algo.item_index_ == original.item_index_) |
277 |
| - assert np.all(algo.user_index_ == original.user_index_) |
278 |
| - |
279 |
| - # make sure it still works |
280 |
| - preds = algo.predict_for_user(10, np.arange(0, 50, dtype="i8")) |
281 |
| - assert len(preds) == 50 |
282 |
| - |
283 |
| - |
284 | 246 | @mark.slow
|
285 | 247 | @mark.eval
|
286 | 248 | @mark.skipif(not lktu.ml100k.available, reason="ML100K data not present")
|
|
0 commit comments