Add tests for probability calculation and hot/cold number functions
This commit is contained in:
1 parent
9d3c01f966
commit
5cb2dbee82
1 file changed
+44
@@ -35,3 +35,47 @@ def test_least_and_most_common_number() -> None:
|
||||
assert analyze.get_least_common_number(pb_df, columns=['powerball'], bottom=1) == [16]
|
||||
assert analyze.get_most_common_number(mm_df, columns=['mega_ball'], top=1) == [1]
|
||||
assert analyze.get_least_common_number(mm_df, columns=['mega_ball'], bottom=1) == [3]
|
||||
|
||||
|
||||
def test_calculate_probabilities() -> None:
|
||||
"""tests build_binary_matrix, build_next_targets and calculate_number_probability"""
|
||||
pb_start = datetime(2015, 10, 4)
|
||||
mm_start = datetime(2025, 4, 5)
|
||||
date_end = datetime(2026, 3, 8)
|
||||
|
||||
pb_df = analyze.load_dataframe(
|
||||
table_name='PowerballDraw', start_date=pb_start, end_date=date_end)
|
||||
pb_probabilities = analyze.calculate_probabilities(data_frame=pb_df, max_number=69)
|
||||
|
||||
mm_df = analyze.load_dataframe(
|
||||
table_name='MegaMillionsDraw', start_date=mm_start, end_date=date_end)
|
||||
mm_probabilities = analyze.calculate_probabilities(data_frame=mm_df, max_number=70)
|
||||
|
||||
assert pb_probabilities[1] == 0.3142857142857143
|
||||
assert mm_probabilities[1] == 0.04225352112676056
|
||||
|
||||
|
||||
def test_hot_cold_numbers() -> None:
|
||||
"""tests get_hot_numbers and get_cold_numbers"""
|
||||
pb_start = datetime(2015, 10, 4)
|
||||
mm_start = datetime(2025, 4, 5)
|
||||
date_end = datetime(2026, 3, 8)
|
||||
|
||||
pb_df = analyze.load_dataframe(
|
||||
table_name='PowerballDraw', start_date=pb_start, end_date=date_end)
|
||||
pb_probs = analyze.calculate_probabilities(data_frame=pb_df, max_number=69)
|
||||
mm_df = analyze.load_dataframe(
|
||||
table_name='MegaMillionsDraw', start_date=mm_start, end_date=date_end)
|
||||
mm_probs = analyze.calculate_probabilities(data_frame=mm_df, max_number=70)
|
||||
|
||||
assert (analyze.get_hot_numbers(probabilities=pb_probs) ==
|
||||
[(13, 1.0), (61, 0.7), (21, 0.6714285714285715), (23, 0.6428571428571428), (28, 0.6428571428571428)])
|
||||
assert (analyze.get_cold_numbers(probabilities=pb_probs) ==
|
||||
[(49, 0.10000000000000009), (26, 0.11428571428571432), (46, 0.11428571428571432),
|
||||
(34, 0.17142857142857149), (65, 0.18571428571428572)])
|
||||
assert (analyze.get_hot_numbers(probabilities=mm_probs) ==
|
||||
[(42, 0.19718309859154928), (18, 0.18309859154929578), (40, 0.18309859154929578),
|
||||
(10, 0.16901408450704225), (49, 0.16901408450704225)])
|
||||
assert (analyze.get_cold_numbers(probabilities=mm_probs) ==
|
||||
[(35, 0.028169014084507043), (51, 0.028169014084507043), (1, 0.04225352112676056),
|
||||
(3, 0.04225352112676056), (20, 0.04225352112676056)])
|
||||
Reference in new issue
Block a user