|
| 1 | +from __future__ import absolute_import |
1 | 2 | import warnings
|
2 |
| -from data_table import score_table |
3 |
| -from constants import MAX_GRE, MIN_GRE, BAD_INPUT_RETURN, MIN_GMAT, MAX_GMAT |
4 |
| - |
5 |
| - |
6 |
| -def _validate_score_input(v,q): |
7 |
| - try: |
8 |
| - verbal = int(v) |
9 |
| - except: |
10 |
| - warnings.warn("Was not able to parse verbal score: {}\nReturning {}".format(v,BAD_INPUT_RETURN)) |
11 |
| - return BAD_INPUT_RETURN,BAD_INPUT_RETURN |
12 |
| - try: |
13 |
| - quant = int(q) |
14 |
| - except: |
15 |
| - warnings.warn("Was not able to parse quant score: {}\nReturning {}".format(q,BAD_INPUT_RETURN)) |
16 |
| - return BAD_INPUT_RETURN, BAD_INPUT_RETURN |
17 |
| - |
18 |
| - if verbal > MAX_GRE or verbal < MIN_GRE: |
19 |
| - warnings.warn("Verbal score of {} is not between {} and {}\nReturning {}".format(verbal,MIN_GRE,MAX_GRE,BAD_INPUT_RETURN)) |
20 |
| - return BAD_INPUT_RETURN, BAD_INPUT_RETURN |
21 |
| - |
22 |
| - if quant > MAX_GRE or quant < MIN_GRE: |
23 |
| - warnings.warn("Quant score of {} is not between {} and {}\nReturning {}".format(quant,MIN_GRE,MAX_GRE,BAD_INPUT_RETURN)) |
24 |
| - return BAD_INPUT_RETURN, BAD_INPUT_RETURN |
25 |
| - |
26 |
| - return verbal, quant |
27 |
| - |
28 |
| -def gre2gmat(gre_verbal,gre_quant): |
29 |
| - """ |
30 |
| - :param gre_verbal: Numeric representation of verbal GRE score |
31 |
| - :type verbal: int |
32 |
| -
|
33 |
| - :param gre_quant: Numeric representation of quantitative GRE score |
34 |
| - :type quant: int |
35 |
| -
|
36 |
| - :return: Predicted GMAT score |
37 |
| - :rtype: int |
38 |
| - """ |
39 |
| - v,q = _validate_score_input(gre_verbal,gre_quant) |
40 |
| - if v == BAD_INPUT_RETURN or q == BAD_INPUT_RETURN: |
41 |
| - gmat = BAD_INPUT_RETURN |
42 |
| - else: |
43 |
| - try: |
44 |
| - gmat = score_table.loc[q,v] |
45 |
| - except KeyError: |
46 |
| - gmat = rough_gre2gmat(gre_verbal=v,gre_quant=q) |
47 |
| - |
48 |
| - return gmat |
49 |
| - |
50 |
| - |
51 |
| -def rough_gre2gmat(gre_verbal,gre_quant): |
52 |
| - """ |
53 |
| - An equation for computing GMAT equivalent taken from: |
54 |
| - https://www.mbacrystalball.com/blog/2014/01/23/gre-to-gmat-score-conversion/ |
55 |
| -
|
56 |
| - :param gre_verbal: Numeric representation of verbal GRE score |
57 |
| - :type verbal: int |
58 |
| -
|
59 |
| - :param gre_quant: Numeric representation of quantitative GRE score |
60 |
| - :type quant: int |
61 |
| -
|
62 |
| - :return: Predicted GMAT score |
63 |
| - :rtype: int |
64 |
| - """ |
65 |
| - |
66 |
| - v,q = _validate_score_input(gre_verbal,gre_quant) |
67 |
| - if v == BAD_INPUT_RETURN or q == BAD_INPUT_RETURN: |
68 |
| - gmat = BAD_INPUT_RETURN |
69 |
| - else: |
70 |
| - gmat = -2080.75 + (6.38 * v) + (10.62 * q) |
71 |
| - if gmat >= MAX_GMAT: |
72 |
| - gmat = MAX_GMAT |
73 |
| - elif gmat <= MIN_GMAT: |
74 |
| - gmat = MIN_GMAT |
75 |
| - |
76 |
| - return int(round(gmat,-1)) |
77 |
| -def rougher_gre2gmat(gre_verbal,gre_quant): |
78 |
| - """ |
79 |
| - A terrible approximation for gmat score. Derived with love by yours truly |
80 |
| - :param gre_verbal: Numeric representation of verbal GRE score |
81 |
| - :type verbal: int |
82 |
| -
|
83 |
| - :param gre_quant: Numeric representation of quantitative GRE score |
84 |
| - :type quant: int |
85 |
| -
|
86 |
| - :return: Predicted GMAT score |
87 |
| - :rtype: int |
88 |
| - """ |
89 |
| - warnings.warn("\nThis function is inappropriately inaccurate.") |
90 |
| - v,q = _validate_score_input(gre_verbal,gre_quant) |
91 |
| - if v == BAD_INPUT_RETURN or q == BAD_INPUT_RETURN: |
92 |
| - gmat = BAD_INPUT_RETURN |
93 |
| - else: |
94 |
| - gmat = (v+q)*2.019 |
95 |
| - |
96 |
| - if gmat >= MAX_GMAT: |
97 |
| - gmat = MAX_GMAT |
98 |
| - elif gmat <= MIN_GMAT: |
99 |
| - gmat = MIN_GMAT |
100 |
| - |
101 |
| - return int(round(gmat,-1)) |
102 |
| - |
103 |
| - |
104 |
| - |
105 |
| - |
106 |
| - |
| 3 | +from .data_table import score_table |
| 4 | +from .constants import MAX_GRE, MIN_GRE, BAD_INPUT_RETURN, MIN_GMAT, MAX_GMAT |
| 5 | + |
| 6 | + |
| 7 | +def _validate_score_input(v, q): |
| 8 | + try: |
| 9 | + verbal = int(v) |
| 10 | + except: |
| 11 | + warnings.warn("Was not able to parse verbal score: {}\nReturning {}".format(v, BAD_INPUT_RETURN)) |
| 12 | + return BAD_INPUT_RETURN, BAD_INPUT_RETURN |
| 13 | + try: |
| 14 | + quant = int(q) |
| 15 | + except: |
| 16 | + warnings.warn("Was not able to parse quant score: {}\nReturning {}".format(q, BAD_INPUT_RETURN)) |
| 17 | + return BAD_INPUT_RETURN, BAD_INPUT_RETURN |
| 18 | + |
| 19 | + if verbal > MAX_GRE or verbal < MIN_GRE: |
| 20 | + warnings.warn("Verbal score of {} is not between {} and {}\nReturning {}".format( |
| 21 | + verbal, MIN_GRE, MAX_GRE, BAD_INPUT_RETURN)) |
| 22 | + return BAD_INPUT_RETURN, BAD_INPUT_RETURN |
| 23 | + |
| 24 | + if quant > MAX_GRE or quant < MIN_GRE: |
| 25 | + warnings.warn("Quant score of {} is not between {} and {}\nReturning {}".format( |
| 26 | + quant, MIN_GRE, MAX_GRE, BAD_INPUT_RETURN)) |
| 27 | + return BAD_INPUT_RETURN, BAD_INPUT_RETURN |
| 28 | + |
| 29 | + return verbal, quant |
| 30 | + |
| 31 | + |
| 32 | +def gre2gmat(gre_verbal, gre_quant): |
| 33 | + """ |
| 34 | + :param gre_verbal: Numeric representation of verbal GRE score |
| 35 | + :type verbal: int |
| 36 | +
|
| 37 | + :param gre_quant: Numeric representation of quantitative GRE score |
| 38 | + :type quant: int |
| 39 | +
|
| 40 | + :return: Predicted GMAT score |
| 41 | + :rtype: int |
| 42 | + """ |
| 43 | + v, q = _validate_score_input(gre_verbal, gre_quant) |
| 44 | + if v == BAD_INPUT_RETURN or q == BAD_INPUT_RETURN: |
| 45 | + gmat = BAD_INPUT_RETURN |
| 46 | + else: |
| 47 | + try: |
| 48 | + gmat = score_table.loc[q, v] |
| 49 | + except KeyError: |
| 50 | + gmat = rough_gre2gmat(gre_verbal=v, gre_quant=q) |
| 51 | + |
| 52 | + return gmat |
| 53 | + |
| 54 | + |
| 55 | +def rough_gre2gmat(gre_verbal, gre_quant): |
| 56 | + """ |
| 57 | + An equation for computing GMAT equivalent taken from: |
| 58 | + https://www.mbacrystalball.com/blog/2014/01/23/gre-to-gmat-score-conversion/ |
| 59 | +
|
| 60 | + :param gre_verbal: Numeric representation of verbal GRE score |
| 61 | + :type verbal: int |
| 62 | +
|
| 63 | + :param gre_quant: Numeric representation of quantitative GRE score |
| 64 | + :type quant: int |
| 65 | +
|
| 66 | + :return: Predicted GMAT score |
| 67 | + :rtype: int |
| 68 | + """ |
| 69 | + |
| 70 | + v, q = _validate_score_input(gre_verbal, gre_quant) |
| 71 | + if v == BAD_INPUT_RETURN or q == BAD_INPUT_RETURN: |
| 72 | + gmat = BAD_INPUT_RETURN |
| 73 | + else: |
| 74 | + gmat = -2080.75 + (6.38 * v) + (10.62 * q) |
| 75 | + if gmat >= MAX_GMAT: |
| 76 | + gmat = MAX_GMAT |
| 77 | + elif gmat <= MIN_GMAT: |
| 78 | + gmat = MIN_GMAT |
| 79 | + |
| 80 | + return int(round(gmat, -1)) |
| 81 | + |
| 82 | + |
| 83 | +def rougher_gre2gmat(gre_verbal, gre_quant): |
| 84 | + """ |
| 85 | + A terrible approximation for gmat score. Derived with love by yours truly |
| 86 | + :param gre_verbal: Numeric representation of verbal GRE score |
| 87 | + :type verbal: int |
| 88 | +
|
| 89 | + :param gre_quant: Numeric representation of quantitative GRE score |
| 90 | + :type quant: int |
| 91 | +
|
| 92 | + :return: Predicted GMAT score |
| 93 | + :rtype: int |
| 94 | + """ |
| 95 | + warnings.warn("\nThis function is inappropriately inaccurate.") |
| 96 | + v, q = _validate_score_input(gre_verbal, gre_quant) |
| 97 | + if v == BAD_INPUT_RETURN or q == BAD_INPUT_RETURN: |
| 98 | + gmat = BAD_INPUT_RETURN |
| 99 | + else: |
| 100 | + gmat = (v + q) * 2.019 |
| 101 | + |
| 102 | + if gmat >= MAX_GMAT: |
| 103 | + gmat = MAX_GMAT |
| 104 | + elif gmat <= MIN_GMAT: |
| 105 | + gmat = MIN_GMAT |
| 106 | + |
| 107 | + return int(round(gmat, -1)) |
0 commit comments