From f68a7c27c2653d43bbb26f8dde3e4443664806ba Mon Sep 17 00:00:00 2001 From: rohithpr Date: Thu, 8 Jan 2015 20:00:53 +0530 Subject: [PATCH 1/8] Added tests for question stats --- tests/input_files/question_1 | 321 ++++++++++++++++++++++ tests/input_files/question_2 | 441 ++++++++++++++++++++++++++++++ tests/test_question_statistics.py | 32 ++- 3 files changed, 792 insertions(+), 2 deletions(-) create mode 100644 tests/input_files/question_1 create mode 100644 tests/input_files/question_2 diff --git a/tests/input_files/question_1 b/tests/input_files/question_1 new file mode 100644 index 0000000..4fcf441 --- /dev/null +++ b/tests/input_files/question_1 @@ -0,0 +1,321 @@ + + +Is there a proof of the Four Color Theorem that does not involve substantial computation? - Quora +
There are updates to this page that haven't been applied because you've entered text. Refresh this page to see updates.

Is there a proof of the Four Color Theorem that does not involve substantial computation?

This is the full question: """The Four Colour Theorem is famous for being the first long-standing mathematical problem to be resolved using a computer program. The theorem was first conjectured in 1852 by Francis Guthrie, and after over a century of work by many famous mathematicians [36,28] (including De Morgan, Peirce, Hamilton, Cayley, Birkhoff, and Lebesgue), and many incorrect “proofs”, it was finally proved by Appel and Haken in 1976 [3]. This proof broke new ground because it involved using computer programs to carry out a gigantic case analysis, which could not, in any real sense, be performed by hand: it covered, quite literally, a billion cases."""... Can we thus say that the correctness of the proof depends on the correctness of the computer program which check all the billion cases… and that the correctness of the program guarantees the correct results for the billion+1th case…? This by itself constitutes a new proof technique(?), in which one can trust a computer program (or algorithm) and assume it correct as an axiom (the same way one assumes the truth of the 5-th postulate of Euclid)… This was my main issue the first time I came across this theorem and it still is… Any thoughts…? [This is my source: http://research.microsoft.com/en...
Alon AmitAlon Amit, PhD in Mathematics; Mathcircler.
45 upvotes by Ori Gurel-Gurevich (Level 17 Mathematician), Alioune Ngom, Arijit Layek, (more)
I think the question is this: is there now a different proof of the four-color theorem that can be written down and comprehended by a human being, as most ordinary math papers are, without relying on substantial computation?

To the best of my knowledge, the answer is No. The most recent significant proof is "A New Proof of the Four-Color Theorem" by Robertson, Sanders, Seymour and Thomas, published in 1996 (in Electronic Research Announcements of the AMS). It substantially simplifies the original 1976 proof by Appel and Haken but it does not remove the need for machine-based computation.

The paper exhibits 633 configurations that are reducible (they cannot occur in a minimal counterexample to the 4CT) and unavoidable (one of them must appear in any planar map, essentially). The number (633) of those configurations is smaller than in the original proof, and the (human-readable) proof of unavoidability is much simpler, but it's still not reasonable to have a person process those 633 configurations by hand.
No. Nobody has yet found a proof which is simple enough to be worked out by hand.

Some people seem aggrieved by that, but I don't get it. I'd rather have a computer running the proof, since computers are more reliable than humans. The way I see it, the program IS the proof, since it runs in finite time, and thus the program itself is as "hand-checked" as you would want any proof to be. The program has been coded several different ways, entirely independently, and checked by many independent sets of researchers.

The way I see it, it's just a more compact version of the proof than the thousands of cases that the program prints out. It's effectively just a different notation.

It would be neat, I suppose, if somebody were to discover a short proof that had somehow been missed by tens of thousands of mathematicians working for a few centuries, but I don't find the lack of it either problematic or enlightening. Finding it might be enlightening. But I suspect that most mathematicians find it more producitve to spend their time on other problems.
Jered Wasburn-MosesJered Wasburn-Moses, Mathematics educator
1 upvote by Alioune Ngom.
I think you misunderstand the proof a little bit, in a very important sense.

First, I do not know your source, but there were fewer than 2,000 cases to be checked. But more fundamentally, the major part of the proof was to show that it was sufficient just to check these finitely-many cases; all maps could, in some sense, be reduced to a combination of them.

Therefore, there is no "billion + 1th case", not just because there were fewer than a billion cases checked, but because these represented all of the cases that needed checking!

For a far more detailed description, see Four color theorem.
Alioune NgomAlioune Ngom, Full Professor in Computer Science
Write an answer
diff --git a/tests/input_files/question_2 b/tests/input_files/question_2 new file mode 100644 index 0000000..c05fa9c --- /dev/null +++ b/tests/input_files/question_2 @@ -0,0 +1,441 @@ + + +If space is 3 dimensional, can time also be 3 dimensional? - Quora +
There are updates to this page that haven't been applied because you've entered text. Refresh this page to see updates.

If space is 3 dimensional, can time also be 3 dimensional?

Brian BiBrian Bi, took mostly theoretical course... (more)
45 upvotes by Quora User, Quora User, Arijit Layek, (more)
There's no reason to believe that time is three-dimensional in the universe we inhabit.

We may, of course, consider the question of whether having three time dimensions makes sense in some hypothetical universe. The answer is: probably not, given our understanding of the nature of space and time. We speak of the time evolution of physical systems, and not "space evolution"; the distinguishing feature of time is precisely that such evolution is meaningful. For, given a snapshot of an isolated system at a given time---that is, time constant but space coordinates allowed to vary---we are supposed to be able to determine what a snapshot of the system would look like at a future time; on the other hand, if we used a hypersurface with a spacelike normal---by giving the state of the system at a fixed spatial coordinate with time and the other two spatial coordinates allowed to vary---we would not be able to reconstruct the system along the third spatial coordinate.

In jargon, we say that "the Cauchy problem is well-posed" when there's exactly one time dimension and consequently the partial differential equations governing physical fields are hyperbolic. With an increase the number of time dimensions, you could still write down PDEs, but the time evolution of spacelike hypersurfaces with all time coordinates fixed would not be determined. If that were the case, you could split up the dimensions into two groups but it would be fairly arbitrary which group you labelled as space and which you labelled as time. This would be nothing like the situation in our universe, in which time has a privileged role.

Of course, everything I've said above assumes that space-time really is the ultimate background against which physical phenomena occur, and that space-time is continuous and physical phenomena are governed by partial differential equations. If space and time turn out to be discrete or emergent phenomena or something like that, what I've said may not necessarily apply.
Todd GardinerTodd Gardiner, Photographer and questioner of... (more)
2 upvotes by Quora User and Ted Holmes.
No, time cannot be three dimensional. Our current understanding of the base "volume" of the universe is that it is made up of spacetime. Spacetime has four dimensions, three spatial and one of time.
Keith AllpressKeith Allpress
2 upvotes by Gayatri Panicker and Quora User.
Who knows? Maybe there is a time axis that is so short it only sticks up into space like tiny velcro hooks. You can make anything multidimensional in mathematics, but its all pointless unless something comes of it. Until that happens, status quo.
Baran BayraktaroğluBaran Bayraktaroğlu, An undergrad in Physics, and d... (more)
In our universe, probably not. Because there is no measure to say, for example, apart from forward and backward, there is also upward, downward, leftward and rightward time directions. It is too complicated even to model it to our universe. Nevertheless, if you can model it and assign the other 2 dimensions of time to some"things" and that it is proven that it works, then I can congratulate you. But for now, no. There doesn't seem to be 2 other time dimensions.
David ChidakelDavid Chidakel, writes the blog http://science... (more)
1 upvote by Quora User.
Our primary direction (arrow of time) is "getting older". This isn't something we can control. We can't go forward and back and certainly can't go side to side or up and down (timewise). If there were extrinsic forces that could propel us in orthogonal time directions we could have a more interesting temporal life but no such forces have every been observed.

Restricted as we are to forward and backward (making allowances for the rate of time flow in inertial frames as per Special Relativity) there's no need to come up with additional time dimensions.

There are, however, other descriptions of the world such as String Theory which have "extra dimensions". In some versions, there are extra time dimensions.
In my  opinion, it can be, but because time evolves, a 3-dimensional time would be like a bundle of strands. Being constrained to a strand makes time one-dimensional. Thus one could have a multiplicity of strands, effectively the "timelines" of SF, but you would only know about one of them, and to retain causality, you could never act on another. Interestingly, though, if you could project your mind normal to a timeline, you could see the past and future, at least to some extent. So your question now is, do you believe in prophecies like those of Nostradamus? Are they real or are they completely bizarre falsehoods? You choose. If real, that would be evidence for multidimensional time. If false, well, no conclusion.
Danny RuijtersDanny Ruijters, wrote first computer program a... (more)
Let's have a little thought experiment. Imagine a universe that consists of only one point (0-dimensional space), and 2-dimensional time. Now let's consider the temperature of this point over time: T(t1,t2). Since we want the time to be causal, let's say that we can only move up (t1) or to the right (t2) in time.

When you would plot the temperature in a graph, then it should be a continuous function over t1,t2. If you take any arbtrirary point in this graph, then there are multiple paths that lead to this point. I.e., there are multiple (infinte) versions of history that are all true.

An observer, who would write down the temperatures encountered over time, however, would have experienced only one time-path, and it would appear to him that time is actually 1-dimensional.

Another observer, however, could have experienced a completely different time-path, to wind up in the same point as the first observer. They would disagree about the history, and they would both be right.

To make this work in a 3-dimensional space, where time is part of the space-time fabric, would be a considerable challange, since you would need to keep the all physical properties continuous over space for each time dimension.
Sujith VijaySujith Vijay, nerd-enabler
1 upvote by Phani Raj.
The problem with additional dimensions of time is causality. There is a simple way to order real numbers, but there is no natural candidate for a total ordering of pairs or triples of real numbers. Without a total ordering, there is no way to distinguish between cause and effect. And if you throw out causality, there is hardly any physics left.
Ashay MandwaryaAshay Mandwarya, BTech student
1 upvote by Dhruv Chouhan.
Space is 4 dimensional, time being the 4th dimension.
Write an answer
diff --git a/tests/test_question_statistics.py b/tests/test_question_statistics.py index 5c74199..fd8b6ba 100644 --- a/tests/test_question_statistics.py +++ b/tests/test_question_statistics.py @@ -1,5 +1,24 @@ -from quora import Quora, Activity +from bs4 import BeautifulSoup from nose import with_setup +from quora import Quora + +EXPECTED_STATS_1 = { + 'want_answers': 1, + 'question_text': u'Is there a proof of the Four Color Theorem that does not involve substantial computation?', + 'topics': [u'Science, Engineering, and Technology', u'Science', u'Formal Sciences', u'Mathematics'], + 'question_details':
This is the full question: """The Four Colour Theorem is famous for being the first long-standing mathematical problem to be resolved using a computer program. The theorem was first conjectured in 1852 by Francis Guthrie, and after over a century of work by many famous mathematicians [36,28] (including De Morgan, Peirce, Hamilton, Cayley, Birkhoff, and Lebesgue), and many incorrect “proofs”, it was finally proved by Appel and Haken in 1976 [3]. This proof broke new ground because it involved using computer programs to carry out a gigantic case analysis, which could not, in any real sense, be performed by hand: it covered, quite literally, a billion cases."""... Can we thus say that the correctness of the proof depends on the correctness of the computer program which check all the billion cases… and that the correctness of the program guarantees the correct results for the billion+1th case…? This by itself constitutes a new proof technique(?), in which one can trust a computer program (or algorithm) and assume it correct as an axiom (the same way one assumes the truth of the 5-th postulate of Euclid)… This was my main issue the first time I came across this theorem and it still is… Any thoughts…? [This is my source: http://research.microsoft.com/en...
, + 'answer_count': 4, + 'answer_wiki': '' + } + +EXPECTED_STATS_2 = { + 'want_answers': 10, + 'question_text': u'If space is 3 dimensional, can time also be 3 dimensional?', + 'topics': [u'Science, Engineering, and Technology', u'Science', u'Physical Sciences', u'Physics', u'Theoretical Physics'], + 'question_details':
, + 'answer_count': 9, + 'answer_wiki': '' + } class TestQuestionStatistics: q = Quora() @@ -24,4 +43,13 @@ def test_exists(self): def test_type(self): for stat in self.test_stats: assert isinstance(stat['answer_count'], (int, long)) - assert isinstance(stat['want_answers'], (int, long)) \ No newline at end of file + assert isinstance(stat['want_answers'], (int, long)) + +class TestQuestionScraper: + q = Quora() + + def test_correct(self): + stats1 = q.scrape_question_stats(BeautifulSoup(open('input_files/question_1'))) + stats2 = q.scrape_question_stats(BeautifulSoup(open('input_files/question_2'))) + assert stats1 == EXPECTED_STATS_1 + assert stats2 == EXPECTED_STATS_2 From bb65bd32dcc576677a8efecf3821a4fce1fbf6a5 Mon Sep 17 00:00:00 2001 From: rohithpr Date: Tue, 20 Jan 2015 23:34:27 +0530 Subject: [PATCH 2/8] Fixed question scraper test --- quora/quora.py | 4 ++-- tests/test_question_statistics.py | 13 ++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/quora/quora.py b/quora/quora.py index 36efec0..b178568 100644 --- a/quora/quora.py +++ b/quora/quora.py @@ -124,8 +124,8 @@ def scrape_question_stats(soup): 'answer_count' : try_cast_int(answer_count), 'question_text' : question_text.string, 'topics' : topics, - 'question_details' : question_details.string, - 'answer_wiki' : answer_wiki.string, + 'question_details' : str(question_details), + 'answer_wiki' : str(answer_wiki), } return question_dict diff --git a/tests/test_question_statistics.py b/tests/test_question_statistics.py index fd8b6ba..44113ce 100644 --- a/tests/test_question_statistics.py +++ b/tests/test_question_statistics.py @@ -1,3 +1,5 @@ +#coding=utf-8 + from bs4 import BeautifulSoup from nose import with_setup from quora import Quora @@ -6,7 +8,7 @@ 'want_answers': 1, 'question_text': u'Is there a proof of the Four Color Theorem that does not involve substantial computation?', 'topics': [u'Science, Engineering, and Technology', u'Science', u'Formal Sciences', u'Mathematics'], - 'question_details':
This is the full question: """The Four Colour Theorem is famous for being the first long-standing mathematical problem to be resolved using a computer program. The theorem was first conjectured in 1852 by Francis Guthrie, and after over a century of work by many famous mathematicians [36,28] (including De Morgan, Peirce, Hamilton, Cayley, Birkhoff, and Lebesgue), and many incorrect “proofs”, it was finally proved by Appel and Haken in 1976 [3]. This proof broke new ground because it involved using computer programs to carry out a gigantic case analysis, which could not, in any real sense, be performed by hand: it covered, quite literally, a billion cases."""... Can we thus say that the correctness of the proof depends on the correctness of the computer program which check all the billion cases… and that the correctness of the program guarantees the correct results for the billion+1th case…? This by itself constitutes a new proof technique(?), in which one can trust a computer program (or algorithm) and assume it correct as an axiom (the same way one assumes the truth of the 5-th postulate of Euclid)… This was my main issue the first time I came across this theorem and it still is… Any thoughts…? [This is my source: http://research.microsoft.com/en...
, + 'question_details': '
This is the full question: """The Four Colour Theorem is famous for being the first long-standing mathematical problem to be resolved using a computer program. The theorem was first conjectured in 1852 by Francis Guthrie, and after over a century of work by many famous mathematicians [36,28] (including De Morgan, Peirce, Hamilton, Cayley, Birkhoff, and Lebesgue), and many incorrect “proofs”, it was finally proved by Appel and Haken in 1976 [3]. This proof broke new ground because it involved using computer programs to carry out a gigantic case analysis, which could not, in any real sense, be performed by hand: it covered, quite literally, a billion cases."""... Can we thus say that the correctness of the proof depends on the correctness of the computer program which check all the billion cases… and that the correctness of the program guarantees the correct results for the billion+1th case…? This by itself constitutes a new proof technique(?), in which one can trust a computer program (or algorithm) and assume it correct as an axiom (the same way one assumes the truth of the 5-th postulate of Euclid)… This was my main issue the first time I came across this theorem and it still is… Any thoughts…? [This is my source: http://research.microsoft.com/en...
', 'answer_count': 4, 'answer_wiki': '' } @@ -15,7 +17,7 @@ 'want_answers': 10, 'question_text': u'If space is 3 dimensional, can time also be 3 dimensional?', 'topics': [u'Science, Engineering, and Technology', u'Science', u'Physical Sciences', u'Physics', u'Theoretical Physics'], - 'question_details':
, + 'question_details': '
', 'answer_count': 9, 'answer_wiki': '' } @@ -46,10 +48,11 @@ def test_type(self): assert isinstance(stat['want_answers'], (int, long)) class TestQuestionScraper: - q = Quora() def test_correct(self): - stats1 = q.scrape_question_stats(BeautifulSoup(open('input_files/question_1'))) - stats2 = q.scrape_question_stats(BeautifulSoup(open('input_files/question_2'))) + q = Quora() + stats1 = q.scrape_question_stats(BeautifulSoup(open('tests/input_files/question_1'))) + stats2 = q.scrape_question_stats(BeautifulSoup(open('tests/input_files/question_2'))) assert stats1 == EXPECTED_STATS_1 assert stats2 == EXPECTED_STATS_2 + From 94ab267f014a1a68528bf448d5e5f0b08efff255 Mon Sep 17 00:00:00 2001 From: rohithpr Date: Sat, 24 Jan 2015 17:46:58 +0530 Subject: [PATCH 3/8] Added test for answer scraper --- quora/quora.py | 2 +- tests/input_files/answer_1 | 196 ++++++++++++++++++++++++++++++ tests/test_answer_statistics.py | 22 ++++ tests/test_question_statistics.py | 2 +- 4 files changed, 220 insertions(+), 2 deletions(-) create mode 100644 tests/input_files/answer_1 create mode 100644 tests/test_answer_statistics.py diff --git a/quora/quora.py b/quora/quora.py index b178568..f30f2a8 100644 --- a/quora/quora.py +++ b/quora/quora.py @@ -15,7 +15,7 @@ def try_cast_int(s): def get_question_link(soup): question_link = soup.find('a', attrs = {'class' : 'question_link'}) - return question_link.get('href') + return 'http://www.quora.com' + question_link.get('href') def get_author(soup): raw_author = soup.find('div', attrs = {'class' : 'author_info'}).next.get('href') diff --git a/tests/input_files/answer_1 b/tests/input_files/answer_1 new file mode 100644 index 0000000..18dc9ec --- /dev/null +++ b/tests/input_files/answer_1 @@ -0,0 +1,196 @@ + + +Mayur P R Rohith's answer to What are some mistakes you noticed on Friends? - Quora +
This page may be out of date. Submit any pending changes before refreshing this page.
diff --git a/tests/test_answer_statistics.py b/tests/test_answer_statistics.py new file mode 100644 index 0000000..2963090 --- /dev/null +++ b/tests/test_answer_statistics.py @@ -0,0 +1,22 @@ +#coding=utf-8 + +from bs4 import BeautifulSoup +from nose import with_setup +from quora import Quora + +EXPECTED_STATS_1 = {'want_answers': 75, + 'views': 195, + 'author': u'Mayur-P-R-Rohith', + 'question_link': u'http://www.quora.com/What-are-some-mistakes-you-noticed-on-Friends', + 'comment_count': 1, + 'answer': '
S4E20:

Notice the whiteboard.
10:02- "get out"

10:21- "Poop"

10:36- "Poop"

10:43- "get out"
', + 'upvote_count': 3, + } + +class TestAnswerScraper: + + def test_correct(self): + q = Quora() + stats1 = q.scrape_one_answer(BeautifulSoup(open('tests/input_files/answer_1'))) + + assert stats1 == EXPECTED_STATS_1 diff --git a/tests/test_question_statistics.py b/tests/test_question_statistics.py index 44113ce..adc54b2 100644 --- a/tests/test_question_statistics.py +++ b/tests/test_question_statistics.py @@ -55,4 +55,4 @@ def test_correct(self): stats2 = q.scrape_question_stats(BeautifulSoup(open('tests/input_files/question_2'))) assert stats1 == EXPECTED_STATS_1 assert stats2 == EXPECTED_STATS_2 - + \ No newline at end of file From bd766630ceadcea1928a8b582a178d49788ecc53 Mon Sep 17 00:00:00 2001 From: rohithpr Date: Mon, 9 Feb 2015 20:20:33 +0530 Subject: [PATCH 4/8] Fix try_cast_int #66 --- quora/quora.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/quora/quora.py b/quora/quora.py index f30f2a8..3aa6d68 100644 --- a/quora/quora.py +++ b/quora/quora.py @@ -6,10 +6,16 @@ # Helpers #################################################################### def try_cast_int(s): - try: - temp = re.findall('\d', str(s)) - temp = ''.join(temp) - return int(temp) + pattern = re.compile(r'([0-9]+(\.[0-9]+)*[ ]*[Kk])|([0-9]+)') + raw_result = re.search(pattern, s).groups() + if raw_result[2] != None: + return int(raw_result[2]) + elif raw_result[1] == None: + raw_result = re.search(r'([0-9]+)', raw_result[0]) + return int(raw_result.groups()[0]) * 1000 + else: + raw_result = re.search(r'([0-9]+)\.([0-9]+)', raw_result[0]).groups() + return int(raw_result[0]) * 1000 + int(raw_result[1]) * 100 except ValueError: return s From 4da1d43e49a5acd743b50a31ba5afe2eb90bc2a5 Mon Sep 17 00:00:00 2001 From: rohithpr Date: Mon, 9 Feb 2015 20:28:07 +0530 Subject: [PATCH 5/8] Test for try_cast_int --- tests/test_helper_functions.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 tests/test_helper_functions.py diff --git a/tests/test_helper_functions.py b/tests/test_helper_functions.py new file mode 100644 index 0000000..91caa6d --- /dev/null +++ b/tests/test_helper_functions.py @@ -0,0 +1,9 @@ +import nose +from quora import try_cast_int + +def test_try_cast_int(): + assert try_cast_int('200 Upvotes') == 200 + assert try_cast_int('2k Upvotes') == 2000 + assert try_cast_int('2 K Upvotes') == 2000 + assert try_cast_int('2.3k Upvotes') == 2300 + assert try_cast_int('2.3 K Upvotes') == 2300 From 62951af9d1299dde4fb07482d63f414a3fd4383f Mon Sep 17 00:00:00 2001 From: rohithpr Date: Mon, 9 Feb 2015 20:30:40 +0530 Subject: [PATCH 6/8] Fix typo --- quora/quora.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/quora/quora.py b/quora/quora.py index 3aa6d68..6605377 100644 --- a/quora/quora.py +++ b/quora/quora.py @@ -6,17 +6,18 @@ # Helpers #################################################################### def try_cast_int(s): - pattern = re.compile(r'([0-9]+(\.[0-9]+)*[ ]*[Kk])|([0-9]+)') - raw_result = re.search(pattern, s).groups() - if raw_result[2] != None: - return int(raw_result[2]) - elif raw_result[1] == None: - raw_result = re.search(r'([0-9]+)', raw_result[0]) - return int(raw_result.groups()[0]) * 1000 - else: - raw_result = re.search(r'([0-9]+)\.([0-9]+)', raw_result[0]).groups() - return int(raw_result[0]) * 1000 + int(raw_result[1]) * 100 - except ValueError: + try: + pattern = re.compile(r'([0-9]+(\.[0-9]+)*[ ]*[Kk])|([0-9]+)') + raw_result = re.search(pattern, s).groups() + if raw_result[2] != None: + return int(raw_result[2]) + elif raw_result[1] == None: + raw_result = re.search(r'([0-9]+)', raw_result[0]) + return int(raw_result.groups()[0]) * 1000 + else: + raw_result = re.search(r'([0-9]+)\.([0-9]+)', raw_result[0]).groups() + return int(raw_result[0]) * 1000 + int(raw_result[1]) * 100 + except: return s def get_question_link(soup): From e8a08ec02285f88fc82647d220f279f7216ba603 Mon Sep 17 00:00:00 2001 From: rohithpr Date: Mon, 9 Feb 2015 20:51:58 +0530 Subject: [PATCH 7/8] Fix import error --- quora/__init__.py | 2 +- tests/test_helper_functions.py | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/quora/__init__.py b/quora/__init__.py index 7f189c4..39344a3 100644 --- a/quora/__init__.py +++ b/quora/__init__.py @@ -1,2 +1,2 @@ from user import User, Activity -from quora import Quora \ No newline at end of file +from quora import Quora,try_cast_int \ No newline at end of file diff --git a/tests/test_helper_functions.py b/tests/test_helper_functions.py index 91caa6d..b329ae3 100644 --- a/tests/test_helper_functions.py +++ b/tests/test_helper_functions.py @@ -1,9 +1,10 @@ -import nose -from quora import try_cast_int +import quora def test_try_cast_int(): - assert try_cast_int('200 Upvotes') == 200 - assert try_cast_int('2k Upvotes') == 2000 - assert try_cast_int('2 K Upvotes') == 2000 - assert try_cast_int('2.3k Upvotes') == 2300 - assert try_cast_int('2.3 K Upvotes') == 2300 + assert quora.try_cast_int('200 Upvotes') == 200 + assert quora.try_cast_int('2k Upvotes') == 2000 + assert quora.try_cast_int('2 K Upvotes') == 2000 + assert quora.try_cast_int('2.3k Upvotes') == 2300 + assert quora.try_cast_int('2.3 K Upvotes') == 2300 + +test_try_cast_int() \ No newline at end of file From 62658432a07539530486ab04d79a717905c3a355 Mon Sep 17 00:00:00 2001 From: rohithpr Date: Mon, 9 Feb 2015 21:16:08 +0530 Subject: [PATCH 8/8] Fix random bug --- quora/quora.py | 2 +- tests/test_helper_functions.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/quora/quora.py b/quora/quora.py index 6605377..f94b5e9 100644 --- a/quora/quora.py +++ b/quora/quora.py @@ -63,7 +63,7 @@ def scrape_one_answer(soup): want_answers = soup.find('span', attrs = {'class' : 'count'}).string try: - upvote_count = soup.find('a', attrs = {'class' : 'vote_item_link'}).find('span', attrs = {'class' : 'count'}) + upvote_count = soup.find('a', attrs = {'class' : 'vote_item_link'}).find('span', attrs = {'class' : 'count'}).string if upvote_count is None: upvote_count = 0 except: diff --git a/tests/test_helper_functions.py b/tests/test_helper_functions.py index b329ae3..f0acff7 100644 --- a/tests/test_helper_functions.py +++ b/tests/test_helper_functions.py @@ -6,5 +6,6 @@ def test_try_cast_int(): assert quora.try_cast_int('2 K Upvotes') == 2000 assert quora.try_cast_int('2.3k Upvotes') == 2300 assert quora.try_cast_int('2.3 K Upvotes') == 2300 + assert quora.try_cast_int('3') == 3 test_try_cast_int() \ No newline at end of file