Skip to content

Commit 1330225

Browse files
committed
test: add unit tests for gowalla, tafeng, and yoochoose datasets
1 parent 2b848ea commit 1330225

File tree

3 files changed

+104
-0
lines changed

3 files changed

+104
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright 2023 The Cornac Authors. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# ============================================================================
15+
16+
import random
17+
import time
18+
import unittest
19+
20+
from cornac.datasets import gowalla
21+
22+
23+
class TestGowalla(unittest.TestCase):
24+
25+
def test_load_checkins(self):
26+
random.seed(time.time())
27+
if random.random() > 0.8:
28+
checkins = gowalla.load_checkins()
29+
self.assertEqual(len(checkins), 6442892)
30+
31+
32+
if __name__ == "__main__":
33+
unittest.main()
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright 2023 The Cornac Authors. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# ============================================================================
15+
16+
import random
17+
import time
18+
import unittest
19+
20+
from cornac.datasets import tafeng
21+
22+
23+
class TestTafeng(unittest.TestCase):
24+
25+
def test_load_basket(self):
26+
random.seed(time.time())
27+
if random.random() > 0.8:
28+
baskets = tafeng.load_basket()
29+
self.assertEqual(len(baskets), 817741)
30+
31+
32+
if __name__ == "__main__":
33+
unittest.main()
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Copyright 2023 The Cornac Authors. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# ============================================================================
15+
16+
import random
17+
import time
18+
import unittest
19+
20+
from cornac.datasets import yoochoose
21+
22+
23+
class TestYooChoose(unittest.TestCase):
24+
25+
def test_load_buy_click_test(self):
26+
random.seed(time.time())
27+
if random.random() > 0.8:
28+
buy = yoochoose.load_buy()
29+
click = yoochoose.load_click()
30+
test = yoochoose.load_test()
31+
32+
self.assertEqual(len(buy), 1150753)
33+
self.assertEqual(len(click), 33003944)
34+
self.assertEqual(len(test), 8251791)
35+
36+
37+
if __name__ == "__main__":
38+
unittest.main()

0 commit comments

Comments
 (0)