Skip to content
This repository has been archived by the owner on Aug 4, 2020. It is now read-only.

Commit

Permalink
Remove numpy dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelmior committed Nov 7, 2013
1 parent cc9570c commit 91aace4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ simplejson
thrift
pycassa
loremipsum
numpy
8 changes: 4 additions & 4 deletions tweets/management/commands/fake_data.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import datetime
import loremipsum
import numpy
import random
import string
import time
Expand All @@ -25,15 +24,16 @@ def handle(self, *args, **options):
max_tweets = int(args[1])

# Generate number of tweets based on a Zipfian distribution
sample = numpy.random.zipf(1.05, max_tweets) - 1
num_tweets = numpy.around(sample / float(max(sample)) * max_tweets, 0)
sample = [random.paretovariate(15) - 1 for x in range(max_tweets)]
normalizer = 1 / float(max(sample)) * max_tweets
num_tweets = [int(x * normalizer) for x in sample]

for i in range(num_users):
username = self.get_username()
cass.save_user(username, {'password': self.get_password()})
creation_date = random.randint(origin, now)

for _ in range(int(num_tweets[i % max_tweets])):
for _ in range(num_tweets[i % max_tweets]):
cass.save_tweet(str(uuid.uuid1()), username, {
'username': username,
'body': self.get_tweet(),
Expand Down

0 comments on commit 91aace4

Please sign in to comment.