Skip to content

Commit c2349a6

Browse files
author
Cam Davidson-Pilon
committed
changing Reddit image and adding arg support
1 parent 134f2ba commit c2349a6

File tree

3 files changed

+174
-145
lines changed

3 files changed

+174
-145
lines changed

Chapter4_TheGreatestTheoremNeverTold/LawOfLargeNumbers.ipynb

Lines changed: 137 additions & 96 deletions
Large diffs are not rendered by default.

Chapter4_TheGreatestTheoremNeverTold/top_pic_comments.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
1+
import sys
2+
13
import numpy as np
24
from IPython.core.display import Image
35

4-
56
import praw
67

78

89
reddit = praw.Reddit("BayesianMethodsForHackers")
910
subreddit = reddit.get_subreddit( "pics" )
1011

1112
top_submissions = subreddit.get_top()
12-
top_submission = top_submissions.next()
13-
while "i.imgur.com" not in top_submission.url:
14-
#make sure it is linking to an image, not a webpage.
13+
14+
15+
n_pic = int( sys.argv[1] ) if sys.argv[1] else 1
16+
17+
i = 0
18+
while i < n_pic:
1519
top_submission = top_submissions.next()
20+
while "i.imgur.com" not in top_submission.url:
21+
#make sure it is linking to an image, not a webpage.
22+
top_submission = top_submissions.next()
23+
i+=1
1624

1725
print "Title of submission: \n", top_submission.title
1826
top_post_url = top_submission.url
@@ -34,6 +42,9 @@
3442

3543
votes = np.array( [ upvotes, downvotes] ).T
3644

45+
46+
47+
3748

3849

3950

0 commit comments

Comments
 (0)