def _filled_user_score(self, user): '''The score for a user for where user is the result of a TwitterUser object.''' if self._community: pop_stats = PopulationStats(self._community_members) community_member_ids = pop_stats.all_user_ids() #num of user's followers/friends in the community friend_overlap = len(self._intersection(user['friend_ids'], \ community_member_ids)) try: friend_percent_overlap = friend_overlap/user['friend_count'] except ZeroDivisionError: friend_percent_overlap = 0 follower_overlap = len(self._intersection(user['follower_ids'], \ community_member_ids)) try: follower_percent_overlap = follower_overlap/user['follower_count'] except ZeroDivisionError: follower_percent_overlap = 0 reply_score = 0 user_stats = UserStats(user, self._community_members) replies = user_stats.replies() member_ids = [user['uid'] for user in self._community_members] for replying_to in replies: if replying_to in member_ids: reply_score += 1 score = follower_percent_overlap + friend_percent_overlap #+ reply_score else: score = 0 return score
def _filled_user_score(self, user): '''The score for a user for where user is the result of a TwitterUser object.''' if self._community: pop_stats = PopulationStats(self._community_members) community_member_ids = pop_stats.all_user_ids() #num of user's followers/friends in the community friend_overlap = len(self._intersection(user['friend_ids'], \ community_member_ids)) try: friend_percent_overlap = friend_overlap / user['friend_count'] except ZeroDivisionError: friend_percent_overlap = 0 follower_overlap = len(self._intersection(user['follower_ids'], \ community_member_ids)) try: follower_percent_overlap = follower_overlap / user[ 'follower_count'] except ZeroDivisionError: follower_percent_overlap = 0 reply_score = 0 user_stats = UserStats(user, self._community_members) replies = user_stats.replies() member_ids = [user['uid'] for user in self._community_members] for replying_to in replies: if replying_to in member_ids: reply_score += 1 score = follower_percent_overlap + friend_percent_overlap #+ reply_score else: score = 0 return score
def test_user_stats_formating(self): user_stats = UserStats() user_stats["bodiky"] += 1 self.assertEqual(user_stats._get_stats_str(), " bodiky = 1\n") user_stats["neco"] += 8 self.assertIn(" neco = 8\n", user_stats._get_stats_str())
def test_user_stats(self): user_stats = UserStats() user_stats["bodiky"] += 1 self.assertEqual(user_stats["bodiky"], 1)