Example #1
0
 def on_exit(self):
     stats = hashkat_dump_stats(self.state)
     print hashkat_dump_stats(self.state)
     # Test that a network with only addition rates grows 1 user per step: 
     self.assertTrue(int(stats["n_agents"]) == self.AGENTS_TO_GROW,
             "Should have the maximum amount of agents!")
     self.assertTrue(int(stats["global_stats"]["n_tweets"]) == 0,
             "Should not have any tweets!")
Example #2
0
 def on_exit_all(self):
     print hashkat_dump_stats(self.state)
     counts = get_tweet_feature_counts(self.tweets)
     self.assertTrue(counts["DoesTweet"] > 0,
                     "Agent type with tweet rate > 0 should tweet.")
     self.assertTrue(
         counts["DoesntTweet"] == 0,
         "Agent type with tweet rate == 0 should NOT tweet. Had " +
         str(counts["DoesntTweet"]) + " tweets")
Example #3
0
 def on_exit_all(self):
     print hashkat_dump_stats(self.state)["global_stats"]
     tweet_counts = get_tweet_feature_counts(self.tweets)
     retweet_counts = get_tweet_feature_counts(self.retweets)
     self.assertTrue(tweet_counts["Region0"] == 0,
                     "Region0 should not retweet in this simulation.")
     self.assertTrue(
         reasonably_close(tweet_counts["LANG_ENGLISH"],
                          tweet_counts["LANG_FRENCH"]),
         "English and French tweets should be within 50% of each other.")
     self.assertTrue(retweet_counts["Region1"] > 0,
                     "Retweets should occur from Region1.")
Example #4
0
    def on_exit(self):
        for agent in hashkat_dump_agents(self.state, dump_follow_sets=True):
            print '<<' + str(agent["id"]) + '>>'
            print "Subs: ", agent["following_set"]
            print "Fans: ", agent["follower_set"]
            print "Region: ", agent["region"]
            print "Ideology: ", agent["ideology"]
            print "Language: ", agent["language"]
            #print json.dumps(agent, indent=4, sort_keys=True)
        stats = hashkat_dump_stats(self.state)["global_stats"]
        self.assertTrue(
            int(stats["n_followers"]) == 6,
            "Every agent should have 2 followers, totalling 6.")
        print "Tweets: ", int(stats["n_tweets"])
        print "Retweets: ", int(stats["n_retweets"])
        max_hop = max(int(rt["retweets_since_origin"]) for rt in self.retweets)
        for i in range(1, max_hop + 1):
            print "Retweets at follower distance " + str(i) + ": ", sum(
                1 for rt in self.retweets
                if int(rt["retweets_since_origin"]) == i)
        self.assertTrue(
            max_hop == 2,
            "Every tweet should be retweeted at most 2 times from origin! Had max follower distance "
            + str(max_hop) + ", should be 2")

        self.assertTrue(int(stats["n_retweets"]) > 0, "Should have retweets!")
        self.assertTrue(
            int(stats["n_retweets"]) <= int(stats["n_tweets"] * 2),
            "Should not have more than twice as many retweets as tweets!")
Example #5
0
 def on_exit(self):
     stats = hashkat_dump_stats(self.state)["global_stats"]
     assert int(stats["n_tweets"]) > 0
     assert int(stats["n_retweets"]) > 0
Example #6
0
 def on_exit(self):
     stats = hashkat_dump_stats(self.state)
     self.retweets[int(self.iteration / 5)] += int(
         stats["global_stats"]["n_retweets"])
Example #7
0
 def on_exit(self):
     stats = hashkat_dump_stats(self.state)["global_stats"]
     self.assertTrue(int(stats["n_tweets"]) > 0)
     self.assertTrue(int(stats["n_retweets"]) > 0)
Example #8
0
 def on_exit(self):
     # Test that a stagnant network does not result in creation events:
     self.assertTrue(hashkat_dump_stats(self.state)["n_agents"] == 0)
     # Test that a stagnant network does not result in step events at all:
     self.assertTrue(hashkat_dump_stats(self.state)["n_steps"] == 0)