repo_id
stringclasses
409 values
prefix
large_stringlengths
34
36.3k
target
large_stringlengths
1
498
assertion_type
stringclasses
31 values
difficulty
stringclasses
8 values
test_file
stringlengths
10
121
test_function
stringlengths
1
104
test_class
stringlengths
0
51
lineno
int32
2
11.3k
commit_idx
int32
aiogram/aiogram
import datetime from typing import Any from aiogram.handlers import ChatMemberHandler from aiogram.types import Chat, ChatMemberMember, ChatMemberUpdated, User class MyHandler(ChatMemberHandler): async def handle(self) -> Any: assert self.event == event assert self...
self.event.from_user
assert
complex_expr
tests/test_handler/test_chat_member.py
handle
MyHandler
21
null
aiogram/aiogram
import datetime import functools from typing import Any, NoReturn import pytest from pydantic import BaseModel from aiogram.dispatcher.event.bases import UNHANDLED, SkipHandler from aiogram.dispatcher.event.handler import HandlerObject from aiogram.dispatcher.event.telegram import TelegramEventObserver from aiogram.d...
f
assert
variable
tests/test_dispatcher/test_event/test_telegram.py
test_register
TestTelegramEventObserver
73
null
aiogram/aiogram
from aiogram.methods import AnswerInlineQuery from aiogram.types import InlineQuery, User class TestInlineQuery: def test_answer_alias(self): inline_query = InlineQuery( id="id", from_user=User(id=42, is_bot=False, first_name="name"), query="query", offset=""...
value
assert
variable
tests/test_api/test_types/test_inline_query.py
test_answer_alias
TestInlineQuery
28
null
aiogram/aiogram
from unittest.mock import AsyncMock, MagicMock, patch import pytest from aiogram.exceptions import CallbackAnswerException from aiogram.methods import AnswerCallbackQuery from aiogram.types import CallbackQuery, User from aiogram.utils.callback_answer import CallbackAnswer, CallbackAnswerMiddleware class TestCallbac...
callback_answer.text
assert
complex_expr
tests/test_utils/test_callback_answer.py
test_answer
TestCallbackAnswerMiddleware
173
null
aiogram/aiogram
import pytest from aiogram.dispatcher.flags import Flag, FlagDecorator, FlagGenerator def flag_fixture() -> Flag: return Flag("test", True) def flag_decorator_fixture(flag: Flag) -> FlagDecorator: return FlagDecorator(flag) def flag_flag_generator() -> FlagGenerator: return FlagGenerator() class TestFl...
generator.foo
assert
complex_expr
tests/test_flags/test_decorator.py
test_getattr
TestFlagGenerator
59
null
aiogram/aiogram
import pytest from aiogram.types import Video, VideoQuality def video_quality(): return VideoQuality( file_id="abc123", file_unique_id="unique123", width=1920, height=1080, codec="h264", ) class TestVideoQuality: def test_instantiation(self, video_quality: VideoQua...
"h264"
assert
string_literal
tests/test_api/test_types/test_video_quality.py
test_instantiation
TestVideoQuality
23
null
aiogram/aiogram
from typing import Any from aiogram.handlers import InlineQueryHandler from aiogram.types import InlineQuery, User class MyHandler(InlineQueryHandler): async def handle(self) -> Any: assert self.event == event assert self.from_user ==
self.event.from_user
assert
complex_expr
tests/test_handler/test_inline_query.py
handle
MyHandler
19
null
aiogram/aiogram
import pytest from aiogram.filters.callback_data import CallbackData from aiogram.types import ( InlineKeyboardButton, InlineKeyboardMarkup, KeyboardButton, ReplyKeyboardMarkup, ) from aiogram.utils.keyboard import ( InlineKeyboardBuilder, KeyboardBuilder, ReplyKeyboardBuilder, ) class Tes...
count
assert
variable
tests/test_utils/test_keyboard.py
test_add
TestKeyboardBuilder
168
null
aiogram/aiogram
from typing import Any from aiogram.handlers import PreCheckoutQueryHandler from aiogram.types import PreCheckoutQuery, User class MyHandler(PreCheckoutQueryHandler): async def handle(self) -> Any: assert self.event ==
event
assert
variable
tests/test_handler/test_pre_checkout_query.py
handle
MyHandler
19
null
aiogram/aiogram
from copy import copy from inspect import isclass import pytest from aiogram.dispatcher.event.handler import FilterObject from aiogram.filters import StateFilter from aiogram.fsm.state import State, StatesGroup from aiogram.types import Update class TestStateFilter: async def test_state_copy(self): clas...
State()
assert
func_call
tests/test_filters/test_state.py
test_state_copy
TestStateFilter
61
null
aiogram/aiogram
import asyncio import time from datetime import datetime from unittest.mock import AsyncMock, patch import pytest from aiogram import Bot, flags from aiogram.dispatcher.event.handler import HandlerObject from aiogram.types import Chat, Message, User from aiogram.utils.chat_action import ChatActionMiddleware, ChatActi...
bot
assert
variable
tests/test_utils/test_chat_action.py
test_factory
TestChatActionSender
46
null
aiogram/aiogram
from typing import Any from aiogram.handlers import PollHandler from aiogram.types import Poll, PollOption class MyHandler(PollHandler): async def handle(self) -> Any: assert self.event == event assert self.question == self.event.question assert sel...
self.event.options
assert
complex_expr
tests/test_handler/test_poll.py
handle
MyHandler
25
null
aiogram/aiogram
from aiogram.client.context_controller import BotContextController from tests.mocked_bot import MockedBot class TestBotContextController: def test_via_model_validate(self, bot: MockedBot): my_model = MyModel.model_validate({"id": 1}, context={"bot": bot}) assert my_model.id == 1 assert my_...
bot
assert
variable
tests/test_api/test_client/test_context_controller.py
test_via_model_validate
TestBotContextController
13
null
aiogram/aiogram
from aiogram.methods import BanChatSenderChat from tests.mocked_bot import MockedBot class TestBanChatSenderChat: async def test_bot_method(self, bot: MockedBot): prepare_result = bot.add_result_for(BanChatSenderChat, ok=True, result=True) response: bool = await bot.ban_chat_sender_chat( ...
prepare_result.result
assert
complex_expr
tests/test_api/test_methods/test_ban_chat_sender_chat.py
test_bot_method
TestBanChatSenderChat
14
null
aiogram/aiogram
import asyncio from collections.abc import AsyncGenerator, AsyncIterable from typing import ( Any, AsyncContextManager, ) from unittest.mock import AsyncMock, patch import aiohttp_socks import pytest from aiohttp import ClientError from aresponses import ResponsesMockServer from aiogram import Bot from aiogra...
None
assert
none_literal
tests/test_api/test_client/test_session/test_aiohttp_session.py
test_create_session
TestAiohttpSession
32
null
aiogram/aiogram
import pytest from aiogram.dispatcher.event.bases import UNHANDLED, SkipHandler, skip from aiogram.dispatcher.event.telegram import TelegramEventObserver from aiogram.dispatcher.router import Router class TestRouter: def test_including_routers(self): router1 = Router() router2 = Router() r...
[]
assert
collection
tests/test_dispatcher/test_router.py
test_including_routers
TestRouter
35
null
aiogram/aiogram
from aiogram.methods import AnswerCallbackQuery from aiogram.types import CallbackQuery, InaccessibleMessage, Message, User class TestCallbackQuery: def test_answer_alias(self): callback_query = CallbackQuery( id="id", from_user=User(id=42, is_bot=False, first_name="name"), chat_instance="chat"...
value
assert
variable
tests/test_api/test_types/test_callback_query.py
test_answer_alias
TestCallbackQuery
19
null
aiogram/aiogram
from aresponses import ResponsesMockServer from aiogram import Bot from aiogram.types import BufferedInputFile, FSInputFile, InputFile, URLInputFile from tests.mocked_bot import MockedBot class TestInputFile: def test_fs_input_file(self): file = FSInputFile(__file__) assert isinstance(file, Input...
0
assert
numeric_literal
tests/test_api/test_types/test_input_file.py
test_fs_input_file
TestInputFile
16
null
aiogram/aiogram
import sys import pytest from aiogram.client.default import Default, DefaultBotProperties from aiogram.enums import ParseMode from aiogram.types import LinkPreviewOptions class TestDefault: def test_init(self): default = Default("test") assert default._name ==
"test"
assert
string_literal
tests/test_api/test_client/test_default.py
test_init
TestDefault
13
null
aiogram/aiogram
from aiogram.methods import DeleteBusinessMessages from tests.mocked_bot import MockedBot class TestDeleteBusinessMessages: async def test_bot_method(self, bot: MockedBot): prepare_result = bot.add_result_for(DeleteBusinessMessages, ok=True, result=True) response: bool = await bot.delete_business_...
prepare_result.result
assert
complex_expr
tests/test_api/test_methods/test_delete_business_messages.py
test_bot_method
TestDeleteBusinessMessages
13
null
aiogram/aiogram
import datetime import re import pytest from aiogram import F from aiogram.filters import Command, CommandObject from aiogram.filters.command import CommandStart from aiogram.types import BotCommand, Chat, Message, User from tests.mocked_bot import MockedBot class TestCommandObject: def test_update_handler_flag...
2
assert
numeric_literal
tests/test_filters/test_command.py
test_update_handler_flags
TestCommandObject
227
null
aiogram/aiogram
import datetime import json from collections.abc import AsyncGenerator from typing import Any, AsyncContextManager from unittest.mock import AsyncMock, patch import pytest from pytz import utc from aiogram import Bot from aiogram.client.default import Default, DefaultBotProperties from aiogram.client.session.base imp...
api
assert
variable
tests/test_api/test_client/test_session/test_base_session.py
test_init_custom_api
TestBaseSession
92
null
aiogram/aiogram
import datetime import functools from typing import Any, NoReturn import pytest from pydantic import BaseModel from aiogram.dispatcher.event.bases import UNHANDLED, SkipHandler from aiogram.dispatcher.event.handler import HandlerObject from aiogram.dispatcher.event.telegram import TelegramEventObserver from aiogram.d...
index + 1
assert
complex_expr
tests/test_dispatcher/test_event/test_telegram.py
test_register_filters_via_decorator
TestTelegramEventObserver
135
null
aiogram/aiogram
from typing import Any from aiogram.handlers import InlineQueryHandler from aiogram.types import InlineQuery, User class MyHandler(InlineQueryHandler): async def handle(self) -> Any: assert self.event == event assert self.from_user == self.event.from_user ...
self.event.query
assert
complex_expr
tests/test_handler/test_inline_query.py
handle
MyHandler
20
null
aiogram/aiogram
from unittest.mock import patch import pytest from aiogram import F from aiogram.dispatcher.event.handler import HandlerObject from aiogram.dispatcher.flags import ( check_flags, extract_flags, extract_flags_from_object, get_flag, ) class TestGetters: def test_extract_flags_from_object(self): ...
func.aiogram_flag
assert
complex_expr
tests/test_flags/test_getter.py
test_extract_flags_from_object
TestGetters
23
null
aiogram/aiogram
from aiogram.methods import BanChatMember from tests.mocked_bot import MockedBot class TestKickChatMember: async def test_bot_method(self, bot: MockedBot): prepare_result = bot.add_result_for(BanChatMember, ok=True, result=True) response: bool = await bot.ban_chat_member(chat_id=-42, user_id=42) ...
prepare_result.result
assert
complex_expr
tests/test_api/test_methods/test_ban_chat_member.py
test_bot_method
TestKickChatMember
11
null
aiogram/aiogram
from typing import Any from aiogram.handlers import CallbackQueryHandler from aiogram.types import CallbackQuery, User class MyHandler(CallbackQueryHandler): async def handle(self) -> Any: assert self.event == event assert self.from_user == self.event.from_user ...
self.message
assert
complex_expr
tests/test_handler/test_callback_query.py
handle
MyHandler
21
null
aiogram/aiogram
import asyncio import time from datetime import datetime from unittest.mock import AsyncMock, patch import pytest from aiogram import Bot, flags from aiogram.dispatcher.event.handler import HandlerObject from aiogram.types import Chat, Message, User from aiogram.utils.chat_action import ChatActionMiddleware, ChatActi...
"OK"
assert
string_literal
tests/test_utils/test_chat_action.py
test_call_default
TestChatActionMiddleware
118
null
aiogram/aiogram
from typing import Any from aiogram.handlers import CallbackQueryHandler from aiogram.types import CallbackQuery, User class MyHandler(CallbackQueryHandler): async def handle(self) -> Any: assert self.event ==
event
assert
variable
tests/test_handler/test_callback_query.py
handle
MyHandler
18
null
aiogram/aiogram
from typing import Any import pytest from aiogram.methods import ( SendAnimation, SendAudio, SendContact, SendDice, SendDocument, SendGame, SendInvoice, SendLocation, SendMediaGroup, SendMessage, SendPaidMedia, SendPhoto, SendPoll, SendSticker, SendVenue, ...
message.chat.id
assert
complex_expr
tests/test_api/test_types/test_inaccessible_message.py
test_as_reply_parameters
TestMessage
47
null
aiogram/aiogram
import pytest from pymongo.errors import PyMongoError from aiogram.fsm.state import State from aiogram.fsm.storage.pymongo import PyMongoStorage, StorageKey from tests.conftest import CHAT_ID, USER_ID PREFIX = "fsm" class TestStateAndDataDoNotAffectEachOther: async def test_state_and_data_do_not_affect_each_othe...
"test"
assert
string_literal
tests/test_fsm/storage/test_pymongo.py
test_state_and_data_do_not_affect_each_other_while_getting
TestStateAndDataDoNotAffectEachOther
111
null
massquantity/LibRecommender
import pytest from libreco.bases import Base def test_base(prepare_pure_data): _, train_data, _, data_info = prepare_pure_data with pytest.raises(
ValueError)
pytest.raises
variable
tests/models/test_base.py
test_base
29
null
massquantity/LibRecommender
import functools from io import StringIO import numpy as np import pandas as pd import pytest from scipy.sparse import csr_matrix from libreco.data import DatasetPure from libreco.utils.similarities import ( _choose_blocks, cosine_sim, jaccard_sim, pearson_sim, ) raw_data = """ user,item,label 1,8,2 ...
ValueError)
pytest.raises
variable
tests/test_similarities.py
test_similarities
58
null
massquantity/LibRecommender
import sys import pytest from libreco.algorithms import ALS, LightGCN, RNN4Rec from tests.utils_data import set_ranking_labels def ptest_knn(model, pd_data): assert model.get_user_embedding().shape[0] == model.n_users assert model.get_user_embedding().shape[1] == model.embed_size assert model.get_item_em...
ValueError)
pytest.raises
variable
tests/test_knn_embed.py
test_get_embeddings
108
null
massquantity/LibRecommender
import sys import pytest import tensorflow as tf from numpy.testing import assert_array_equal from libreco.algorithms import YouTubeRanking from tests.models.utils_tf import ptest_tf_variables from tests.utils_data import set_ranking_labels from tests.utils_metrics import get_metrics from tests.utils_multi_sparse_mod...
ValueError)
pytest.raises
variable
tests/models/test_youtube_ranking.py
test_youtube_ranking
70
null
massquantity/LibRecommender
import sys import pytest import tensorflow as tf from numpy.testing import assert_array_equal from libreco.algorithms import TwoTower from tests.models.utils_tf import ptest_tf_variables from tests.utils_data import set_ranking_labels from tests.utils_metrics import get_metrics from tests.utils_pred import ptest_pred...
ValueError)
pytest.raises
variable
tests/models/test_two_tower.py
test_two_tower
70
null
massquantity/LibRecommender
import subprocess import pytest from libreco.bases import CfBase from libserving.serialization import knn2redis, save_knn from tests.utils_data import SAVE_PATH @pytest.mark.parametrize("knn_model", ["UserCF", "ItemCF"], indirect=True) def test_knn_serving(knn_model, session, close_server): assert isinstance(knn...
3
assert
numeric_literal
tests/serving/test_knn_serving.py
test_knn_serving
32
null
massquantity/LibRecommender
import sys import numpy as np import pytest from numpy.testing import assert_allclose, assert_array_equal from libreco.layers import ( conv_nn, dense_nn, layer_normalization, max_pool, multi_head_attention, rms_norm, shared_dense, tf_dense, tf_rnn, ) from libreco.layers.activation ...
labels)
assert_*
variable
tests/test_tf_layers.py
test_layer_norm
150
null
massquantity/LibRecommender
import os.path from io import StringIO import numpy as np import pandas as pd import pytest from numpy.testing import assert_array_equal from scipy.sparse import csr_matrix from libreco.data import ( DataInfo, DatasetFeat, DatasetPure, TransformedEvalSet, TransformedSet, process_data, ) from l...
ValueError)
pytest.raises
variable
tests/test_data.py
test_dataset_pure
95
null
massquantity/LibRecommender
import sys import pytest import tensorflow as tf from libreco.algorithms import FM from tests.models.utils_tf import ptest_tf_variables from tests.utils_data import SAVE_PATH, remove_path, set_ranking_labels from tests.utils_metrics import get_metrics from tests.utils_multi_sparse_models import fit_multi_sparse from ...
ValueError)
pytest.raises
variable
tests/models/test_fm.py
test_fm
65
null
massquantity/LibRecommender
import sys from pathlib import Path import pandas as pd import pytest from libreco.algorithms import RsItemCF, RsUserCF from libreco.data import DataInfo, DatasetPure, split_by_ratio_chrono from libreco.evaluation import evaluate from tests.utils_data import SAVE_PATH, remove_path from tests.utils_pred import ptest_p...
eval_result["roc_auc"]
assert
complex_expr
tests/retrain/test_rs_cf_retrain.py
test_rs_cf_retrain
134
null
massquantity/LibRecommender
import os import sys from pathlib import Path import pandas as pd import pytest import tensorflow as tf from numpy.testing import assert_array_equal from libreco.algorithms import DIN from libreco.data import DatasetFeat, split_by_ratio_chrono from tests.models.utils_tf import ptest_tf_variables from tests.utils_data...
ValueError)
pytest.raises
variable
tests/models/test_din.py
test_din
73
null
massquantity/LibRecommender
import sys import pytest import tensorflow as tf from libreco.algorithms import LightGCN from tests.utils_data import remove_path, set_ranking_labels from tests.utils_metrics import get_metrics from tests.utils_pred import ptest_preds from tests.utils_reco import ptest_recommends from tests.utils_save_load import sav...
AssertionError)
pytest.raises
variable
tests/models/test_lightgcn.py
test_lightgcn
75
null
massquantity/LibRecommender
import json import os import numpy as np import pytest from tensorflow.core.protobuf.meta_graph_pb2 import MetaGraphDef from libreco.bases import CfBase, TfBase from libreco.tfops import tf from libserving.serialization import ( embed2redis, knn2redis, online2redis, save_embed, save_knn, save...
m["model_name"]
assert
complex_expr
tests/serving/test_serialization.py
check_model_name
104
null
massquantity/LibRecommender
import numpy as np import pytest from libreco.recommendation import rank_recommendations def test_rank_reco(): user_ids = [1, 2] preds = np.array([-0.1, -0.01, 0, 0.1, 0.01, 1, -2, 4, 5, 6]) n_rec = 2 n_items = 5 consumed = {1: [3, 4], 2: [4]} with pytest.raises(ValueError): _ = rank_...
[2, 1])
assert_*
collection
tests/test_rank_reco.py
test_rank_reco
39
null
massquantity/LibRecommender
import sys import pytest import tensorflow as tf from libreco.algorithms import AutoInt from tests.models.utils_tf import ptest_tf_variables from tests.utils_metrics import get_metrics from tests.utils_multi_sparse_models import fit_multi_sparse from tests.utils_pred import ptest_preds from tests.utils_reco import pt...
ValueError)
pytest.raises
variable
tests/models/test_autoint.py
test_autoint
52
null
massquantity/LibRecommender
import sys import pytest import tensorflow as tf from libreco.algorithms import SVDpp from libreco.data import DatasetPure from tests.models.utils_tf import ptest_tf_variables from tests.utils_data import SAVE_PATH, set_ranking_labels from tests.utils_metrics import get_metrics from tests.utils_pred import ptest_pred...
ValueError)
pytest.raises
variable
tests/models/test_svdpp.py
test_svdpp
59
null
massquantity/LibRecommender
from io import StringIO import numpy as np import pandas as pd import pytest import torch from libreco.algorithms import DIN, LightGCN, PinSageDGL, RNN4Rec from libreco.batch.batch_data import BatchData from libreco.batch.batch_unit import ( PairFeats, PairwiseBatch, PointwiseBatch, PointwiseSepFeatBa...
(3, 2)
assert
collection
tests/test_collators.py
test_sparse_collator
191
null
massquantity/LibRecommender
import sys import numpy as np import pytest import tensorflow as tf from numpy.testing import assert_array_equal from libreco.algorithms import SIM from tests.models.utils_tf import ptest_tf_variables from tests.utils_data import set_ranking_labels from tests.utils_metrics import get_metrics from tests.utils_multi_sp...
len(cold2)
assert
func_call
tests/models/test_sim.py
long_short_seq_ptest
154
null
massquantity/LibRecommender
from io import StringIO import pandas as pd from libreco.data import ( random_split, split_by_num, split_by_num_chrono, split_by_ratio, split_by_ratio_chrono, ) raw_data = StringIO( """ user,item,label,time 4617,296,2,964138229 4617,296,2,964138221 4617,296,2,964138222 1298,208,4,974849526 45...
6
assert
numeric_literal
tests/test_split_data.py
test_random_split
51
null
massquantity/LibRecommender
import pytest import tensorflow as tf from libreco.algorithms import Transformer from tests.models.utils_tf import ptest_tf_variables from tests.utils_metrics import get_metrics from tests.utils_multi_sparse_models import fit_multi_sparse from tests.utils_pred import ptest_preds from tests.utils_reco import ptest_dyn_...
ValueError)
pytest.raises
variable
tests/models/test_transformer.py
test_transformer
47
null
massquantity/LibRecommender
import numpy as np import pytest from libreco.utils.constants import FeatModels, SequenceModels def recommend_in_former_consumed(data_info, reco, user): user_id = data_info.user2id[user] user_consumed = data_info.user_consumed[user_id] user_consumed_id = [data_info.id2item[i] for i in user_consumed] r...
len(reco2)
assert
func_call
tests/utils_reco.py
ptest_dyn_recommends
119
null
massquantity/LibRecommender
from io import StringIO import numpy as np import pandas as pd import pytest import torch from libreco.algorithms import DIN, LightGCN, PinSageDGL, RNN4Rec from libreco.batch.batch_data import BatchData from libreco.batch.batch_unit import ( PairFeats, PairwiseBatch, PointwiseBatch, PointwiseSepFeatBa...
9
assert
numeric_literal
tests/test_collators.py
test_pairwise_collator
344
null
massquantity/LibRecommender
import os.path from io import StringIO import numpy as np import pandas as pd import pytest from numpy.testing import assert_array_equal from scipy.sparse import csr_matrix from libreco.data import ( DataInfo, DatasetFeat, DatasetPure, TransformedEvalSet, TransformedSet, process_data, ) from l...
10
assert
numeric_literal
tests/test_data.py
test_data_info
149
null
massquantity/LibRecommender
import subprocess from pathlib import Path from libserving.serialization import embed2redis, save_embed, save_faiss_index from tests.utils_data import SAVE_PATH, remove_path def test_embed_serving(embed_model, session, close_server): save_embed(SAVE_PATH, embed_model) embed2redis(SAVE_PATH) faiss_path = s...
1
assert
numeric_literal
tests/serving/test_embed_serving.py
test_embed_serving
26
null
massquantity/LibRecommender
import sys import numpy as np import pandas as pd import pytest from libreco.algorithms import Swing from libreco.data import DatasetPure from tests.utils_data import SAVE_PATH, remove_path, set_ranking_labels from tests.utils_metrics import get_metrics from tests.utils_pred import ptest_preds from tests.utils_reco i...
ValueError)
pytest.raises
variable
tests/models/test_swing.py
test_swing
48
null
massquantity/LibRecommender
from io import StringIO import pandas as pd from libreco.data import ( random_split, split_by_num, split_by_num_chrono, split_by_ratio, split_by_ratio_chrono, ) raw_data = StringIO( """ user,item,label,time 4617,296,2,964138229 4617,296,2,964138221 4617,296,2,964138222 1298,208,4,974849526 45...
0
assert
numeric_literal
tests/test_split_data.py
test_random_split
64
null
massquantity/LibRecommender
from io import StringIO import numpy as np import pandas as pd import pytest import torch from libreco.algorithms import DIN, LightGCN, PinSageDGL, RNN4Rec from libreco.batch.batch_data import BatchData from libreco.batch.batch_unit import ( PairFeats, PairwiseBatch, PointwiseBatch, PointwiseSepFeatBa...
negatives[1][:4]
assert
complex_expr
tests/test_collators.py
test_negatives_exceed_sampling_tolerance
413
null
massquantity/LibRecommender
import json import os import numpy as np import pytest from tensorflow.core.protobuf.meta_graph_pb2 import MetaGraphDef from libreco.bases import CfBase, TfBase from libreco.tfops import tf from libserving.serialization import ( embed2redis, knn2redis, online2redis, save_embed, save_knn, save...
data_info.n_items
assert
complex_expr
tests/serving/test_serialization.py
check_features
159
null
massquantity/LibRecommender
from pathlib import Path import pandas as pd import pytest import tensorflow as tf from libreco.algorithms import TwoTower from libreco.data import DataInfo, DatasetFeat, split_by_ratio_chrono from libreco.evaluation import evaluate from tests.utils_data import SAVE_PATH, remove_path from tests.utils_pred import ptes...
eval_result["roc_auc"]
assert
complex_expr
tests/retrain/test_two_tower_retrain.py
test_two_tower_retrain
177
null
massquantity/LibRecommender
import sys import pytest from libreco.algorithms import ALS, LightGCN, RNN4Rec from tests.utils_data import set_ranking_labels def ptest_knn(model, pd_data): assert model.get_user_embedding().shape[0] == model.n_users assert model.get_user_embedding().shape[1] == model.embed_size assert model.get_item_em...
"cosine"
assert
string_literal
tests/test_knn_embed.py
ptest_knn
68
null
massquantity/LibRecommender
import sys from pathlib import Path import numpy as np import pandas as pd import pytest from libreco.algorithms import Swing from libreco.data import DataInfo, DatasetPure, split_by_ratio_chrono from libreco.evaluation import evaluate from tests.utils_data import SAVE_PATH, remove_path from tests.utils_reco import p...
0
assert
numeric_literal
tests/retrain/test_rs_swing_retrain.py
ptest_preds
174
null
massquantity/LibRecommender
import sys import pytest import tensorflow as tf from numpy.testing import assert_array_equal from libreco.algorithms import RNN4Rec from tests.models.utils_tf import ptest_tf_variables from tests.utils_data import set_ranking_labels from tests.utils_metrics import get_metrics from tests.utils_pred import ptest_preds...
ValueError)
pytest.raises
variable
tests/models/test_rnn4rec.py
test_rnn4rec
70
null
massquantity/LibRecommender
import itertools import numpy as np import pytest from libreco.utils.initializers import ( he_init, truncated_normal, variance_scaling, xavier_init, ) def test_initializers(): np_rng = np.random.default_rng(42) mean, std, fan_in, fan_out, scale = 0.1, 0.01, 4, 2, 2.5 variables = truncated...
ValueError)
pytest.raises
variable
tests/test_initializers.py
test_initializers
41
null
massquantity/LibRecommender
import numpy as np import pytest from libreco.recommendation import rank_recommendations def test_rank_random(): user_ids = [1, 2] # fmt: off preds = np.array([-0.1, -1e8, 0, 0.1, 0.01, 1e8, -0.01, 1e7, 0.1, 0.01]) # inf probs n_rec = 2 n_items = 5 consumed = {1: [3, 4], 2: [4]} rec_item...
score[i]
assert
complex_expr
tests/test_rank_reco.py
test_rank_random
143
null
massquantity/LibRecommender
import sys import pytest from libreco.data.consumed import _fill_empty, _merge_dedup, interaction_consumed def test_merge_remove_duplicates(): num = 3 old_consumed = {0: [1, 2, 3], 1: [4, 5]} new_consumed = {0: [2, 1], 2: [7, 8]} consumed = _merge_dedup(new_consumed, num, old_consumed) assert con...
[4, 5]
assert
collection
tests/test_consumed.py
test_merge_remove_duplicates
54
null
massquantity/LibRecommender
import os.path from io import StringIO import numpy as np import pandas as pd import pytest from numpy.testing import assert_array_equal from scipy.sparse import csr_matrix from libreco.data import ( DataInfo, DatasetFeat, DatasetPure, TransformedEvalSet, TransformedSet, process_data, ) from l...
RuntimeError)
pytest.raises
variable
tests/test_data.py
test_dataset_pure
99
null
massquantity/LibRecommender
from io import StringIO import numpy as np import pandas as pd import pytest import torch from libreco.algorithms import DIN, LightGCN, PinSageDGL, RNN4Rec from libreco.batch.batch_data import BatchData from libreco.batch.batch_unit import ( PairFeats, PairwiseBatch, PointwiseBatch, PointwiseSepFeatBa...
sparse_len
assert
variable
tests/test_collators.py
test_pointwise_collator
261
null
massquantity/LibRecommender
import sys import pytest import tensorflow as tf from libreco.algorithms import DeepFM from tests.models.utils_tf import ptest_tf_variables from tests.utils_data import set_ranking_labels from tests.utils_metrics import get_metrics from tests.utils_multi_sparse_models import fit_multi_sparse from tests.utils_pred imp...
ValueError)
pytest.raises
variable
tests/models/test_deepfm.py
test_deepfm
64
null
massquantity/LibRecommender
from io import StringIO import numpy as np import pandas as pd import pytest import torch from libreco.algorithms import DIN, LightGCN, PinSageDGL, RNN4Rec from libreco.batch.batch_data import BatchData from libreco.batch.batch_unit import ( PairFeats, PairwiseBatch, PointwiseBatch, PointwiseSepFeatBa...
(3, 10)
assert
collection
tests/test_collators.py
test_normal_collator
109
null
massquantity/LibRecommender
import os.path from io import StringIO import numpy as np import pandas as pd import pytest from numpy.testing import assert_array_equal from scipy.sparse import csr_matrix from libreco.data import ( DataInfo, DatasetFeat, DatasetPure, TransformedEvalSet, TransformedSet, process_data, ) from l...
[1, 2, 8]
assert
collection
tests/test_data.py
test_transformed_evalset
206
null
massquantity/LibRecommender
import pytest import tensorflow as tf from numpy.testing import assert_array_equal from libreco.algorithms import YouTubeRetrieval from tests.models.utils_tf import ptest_tf_variables from tests.utils_data import SAVE_PATH, remove_path, set_ranking_labels from tests.utils_metrics import get_metrics from tests.utils_pr...
ValueError)
pytest.raises
variable
tests/models/test_youtube_retrieval.py
test_youtube_retrieval
96
null
massquantity/LibRecommender
import json import os import numpy as np import pytest from tensorflow.core.protobuf.meta_graph_pb2 import MetaGraphDef from libreco.bases import CfBase, TfBase from libreco.tfops import tf from libserving.serialization import ( embed2redis, knn2redis, online2redis, save_embed, save_knn, save...
user2id
assert
variable
tests/serving/test_serialization.py
check_id_mapping
121
null
massquantity/LibRecommender
import os.path from io import StringIO import numpy as np import pandas as pd import pytest from numpy.testing import assert_array_equal from scipy.sparse import csr_matrix from libreco.data import ( DataInfo, DatasetFeat, DatasetPure, TransformedEvalSet, TransformedSet, process_data, ) from l...
2
assert
numeric_literal
tests/test_data.py
test_dataset_feat
112
null
massquantity/LibRecommender
from pathlib import Path import pandas as pd import pytest import tensorflow as tf from libreco.algorithms import DIN from libreco.data import DataInfo, DatasetFeat, split_by_ratio_chrono from libreco.evaluation import evaluate from tests.utils_data import SAVE_PATH, remove_path from tests.utils_pred import ptest_pre...
eval_result["roc_auc"]
assert
complex_expr
tests/retrain/test_tfmodel_retrain_feat.py
test_tfmodel_retrain_feat
159
null
massquantity/LibRecommender
import os import sys from pathlib import Path import pandas as pd import pytest import tensorflow as tf from numpy.testing import assert_array_equal from libreco.algorithms import DIN from libreco.data import DatasetFeat, split_by_ratio_chrono from tests.models.utils_tf import ptest_tf_variables from tests.utils_data...
loaded_dyn_rec)
assert_*
variable
tests/models/test_din.py
test_din_multi_sparse
130
null
massquantity/LibRecommender
from io import StringIO import numpy as np import pandas as pd import pytest import torch from libreco.algorithms import DIN, LightGCN, PinSageDGL, RNN4Rec from libreco.batch.batch_data import BatchData from libreco.batch.batch_unit import ( PairFeats, PairwiseBatch, PointwiseBatch, PointwiseSepFeatBa...
(9,)
assert
collection
tests/test_collators.py
test_normal_collator
114
null
massquantity/LibRecommender
import sys import pytest from libreco.data.consumed import _fill_empty, _merge_dedup, interaction_consumed @pytest.mark.skipif( sys.version_info[:2] < (3, 7), reason="Rust implementation only supports Python >= 3.7.", ) def test_remove_consecutive_duplicates(): user_indices = [1, 1, 1, 2, 2, 1, 2, 3, 2, ...
[1, 2]
assert
collection
tests/test_consumed.py
test_remove_consecutive_duplicates
24
null
massquantity/LibRecommender
import sys import pytest import tensorflow as tf from libreco.algorithms import BPR from tests.models.utils_tf import ptest_tf_variables from tests.utils_data import remove_path from tests.utils_metrics import get_metrics from tests.utils_pred import ptest_preds from tests.utils_reco import ptest_recommends from test...
RuntimeError)
pytest.raises
variable
tests/models/test_bpr.py
test_bpr
111
null
massquantity/LibRecommender
import multiprocessing import random import numpy as np import pytest import torch from torch.utils.data import DataLoader def get_data(request): data_size = 20 same_seed = request.param["same_seed"] batch_size = request.param["batch_size"] num_workers = request.param["num_workers"] batch_data = B...
len(np_random)
assert
func_call
tests/test_multiprocessing_seeds.py
test_multiprocessing_seeds
91
null
massquantity/LibRecommender
from pathlib import Path import pandas as pd import tensorflow as tf from libreco.algorithms import GraphSage from libreco.data import DataInfo, DatasetFeat, split_by_ratio_chrono from libreco.evaluation import evaluate from tests.utils_data import SAVE_PATH, remove_path from tests.utils_pred import ptest_preds from ...
eval_result["roc_auc"]
assert
complex_expr
tests/retrain/test_thmodel_retrain_feat.py
test_torchmodel_retrain_feat
173
null
massquantity/LibRecommender
import itertools import numpy as np import pytest from libreco.utils.initializers import ( he_init, truncated_normal, variance_scaling, xavier_init, ) def variables_in_range(variables, mean, std): for v in itertools.chain.from_iterable(variables): assert (mean - 3 * std) <
v
assert
variable
tests/test_initializers.py
variables_in_range
47
null
massquantity/LibRecommender
import sys import pytest import tensorflow as tf from libreco.algorithms import SVD from tests.models.utils_tf import ptest_tf_variables from tests.utils_data import set_ranking_labels from tests.utils_metrics import get_metrics from tests.utils_pred import ptest_preds from tests.utils_reco import ptest_recommends fr...
ValueError)
pytest.raises
variable
tests/models/test_svd.py
test_svd
57
null
massquantity/LibRecommender
import pytest from libreco.algorithms import ALS from libreco.algorithms.als import least_squares, least_squares_cg from libreco.evaluation import evaluate from tests.utils_data import SAVE_PATH, remove_path, set_ranking_labels from tests.utils_metrics import get_metrics from tests.utils_pred import ptest_preds from t...
TypeError)
pytest.raises
variable
tests/models/test_als.py
test_als
78
null
massquantity/LibRecommender
import importlib import sys import pytest from libreco.graph import check_dgl def test_dgl(prepare_feat_data, monkeypatch): *_, data_info = prepare_feat_data with monkeypatch.context() as m: m.setitem(sys.modules, "dgl", None) with pytest.raises(ModuleNotFoundError): from libreco...
None
assert
none_literal
tests/test_dgl.py
test_dgl
28
null
massquantity/LibRecommender
import os from dataclasses import astuple from pathlib import Path import numpy as np import pandas as pd import pytest from numpy.testing import assert_array_equal from libreco.data import DatasetFeat from libreco.data.data_info import EmptyFeature, Feature, store_old_info from libreco.feature.multi_sparse import ( ...
[2, 4])
assert_*
collection
tests/test_feature.py
test_multi_sparse_indices
297
null
massquantity/LibRecommender
import sys import pytest import tensorflow as tf from numpy.testing import assert_array_equal from libreco.algorithms import RNN4Rec from tests.models.utils_tf import ptest_tf_variables from tests.utils_data import set_ranking_labels from tests.utils_metrics import get_metrics from tests.utils_pred import ptest_preds...
RuntimeError)
pytest.raises
variable
tests/models/test_rnn4rec.py
test_rnn4rec
123
null
massquantity/LibRecommender
import numpy as np import pytest from libreco.utils.constants import FeatModels, SequenceModels def recommend_in_former_consumed(data_info, reco, user): user_id = data_info.user2id[user] user_consumed = data_info.user_consumed[user_id] user_consumed_id = [data_info.id2item[i] for i in user_consumed] r...
len(cold2)
assert
func_call
tests/utils_reco.py
ptest_dyn_recommends
124
null
massquantity/LibRecommender
import sys import pytest import tensorflow as tf from libreco.algorithms import WideDeep from tests.models.utils_tf import ptest_tf_variables from tests.utils_data import set_ranking_labels from tests.utils_metrics import get_metrics from tests.utils_multi_sparse_models import fit_multi_sparse from tests.utils_pred i...
ValueError)
pytest.raises
variable
tests/models/test_wide_deep.py
test_wide_deep
70
null
massquantity/LibRecommender
import sys import pytest import tensorflow as tf from numpy.testing import assert_array_equal from libreco.algorithms import RNN4Rec from tests.models.utils_tf import ptest_tf_variables from tests.utils_data import set_ranking_labels from tests.utils_metrics import get_metrics from tests.utils_pred import ptest_preds...
AssertionError)
pytest.raises
variable
tests/models/test_rnn4rec.py
test_rnn4rec
67
null
massquantity/LibRecommender
import os.path from io import StringIO import numpy as np import pandas as pd import pytest from numpy.testing import assert_array_equal from scipy.sparse import csr_matrix from libreco.data import ( DataInfo, DatasetFeat, DatasetPure, TransformedEvalSet, TransformedSet, process_data, ) from l...
1
assert
numeric_literal
tests/test_data.py
test_dataset_feat
111
null
massquantity/LibRecommender
import json import os import numpy as np import pytest from tensorflow.core.protobuf.meta_graph_pb2 import MetaGraphDef from libreco.bases import CfBase, TfBase from libreco.tfops import tf from libserving.serialization import ( embed2redis, knn2redis, online2redis, save_embed, save_knn, save...
id2item
assert
variable
tests/serving/test_serialization.py
check_id_mapping
133
null
massquantity/LibRecommender
import sys import pytest import tensorflow as tf from libreco.algorithms import AutoInt from tests.models.utils_tf import ptest_tf_variables from tests.utils_metrics import get_metrics from tests.utils_multi_sparse_models import fit_multi_sparse from tests.utils_pred import ptest_preds from tests.utils_reco import pt...
RuntimeError)
pytest.raises
variable
tests/models/test_autoint.py
test_autoint_multi_sparse
98
null
massquantity/LibRecommender
import sys import pytest from libreco.algorithms import ALS, LightGCN, RNN4Rec from tests.utils_data import set_ranking_labels def ptest_knn(model, pd_data): assert model.get_user_embedding().shape[0] == model.n_users assert model.get_user_embedding().shape[1] == model.embed_size assert model.get_item_em...
model.n_items
assert
complex_expr
tests/test_knn_embed.py
test_get_embeddings
98
null
massquantity/LibRecommender
import sys import numpy as np import pytest import tensorflow as tf from numpy.testing import assert_array_equal from libreco.algorithms import SIM from tests.models.utils_tf import ptest_tf_variables from tests.utils_data import set_ranking_labels from tests.utils_metrics import get_metrics from tests.utils_multi_sp...
loaded_dyn_rec)
assert_*
variable
tests/models/test_sim.py
test_sim_multi_sparse
130
null
massquantity/LibRecommender
import numpy as np from libreco.prediction import predict_data_with_feats def ptest_preds(model, task, pd_data, with_feats): user = pd_data.user.iloc[0] item = pd_data.item.iloc[0] pred = model.predict(user=user, item=item) # prediction in range if task == "rating": assert 1 <=
pred
assert
variable
tests/utils_pred.py
ptest_preds
12
null
massquantity/LibRecommender
import sys import pytest import tensorflow as tf from libreco.algorithms import NCF from tests.models.utils_tf import ptest_tf_variables from tests.utils_data import set_ranking_labels from tests.utils_metrics import get_metrics from tests.utils_pred import ptest_preds from tests.utils_reco import ptest_recommends fr...
AssertionError)
pytest.raises
variable
tests/models/test_ncf.py
test_ncf
61
null
massquantity/LibRecommender
import sys import numpy as np import pytest from numpy.testing import assert_allclose, assert_array_equal from libreco.layers import ( conv_nn, dense_nn, layer_normalization, max_pool, multi_head_attention, rms_norm, shared_dense, tf_dense, tf_rnn, ) from libreco.layers.activation ...
(100, 9, 2)
assert
collection
tests/test_tf_layers.py
test_conv_layer
100
null
massquantity/LibRecommender
from pathlib import Path import pandas as pd from libreco.algorithms import NGCF from libreco.data import DataInfo, DatasetPure, split_by_ratio_chrono from libreco.evaluation import evaluate from tests.utils_data import SAVE_PATH, remove_path from tests.utils_pred import ptest_preds from tests.utils_reco import ptest...
eval_result["roc_auc"]
assert
complex_expr
tests/retrain/test_thmodel_retrain_pure.py
test_torchmodel_retrain_pure
134
null
massquantity/LibRecommender
import os from dataclasses import astuple from pathlib import Path import numpy as np import pandas as pd import pytest from numpy.testing import assert_array_equal from libreco.data import DatasetFeat from libreco.data.data_info import EmptyFeature, Feature, store_old_info from libreco.feature.multi_sparse import ( ...
dense_cols
assert
variable
tests/test_feature.py
test_sparse_indices
171
null