From 71c540d49bf434c12788ef790672525e6350ec20 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Sun, 8 Mar 2026 19:32:24 -0400 Subject: [PATCH 1/7] Remove env var import, unneeded --- lottery_predictor/analyze.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/lottery_predictor/analyze.py b/lottery_predictor/analyze.py index 72a8e51..a871a83 100644 --- a/lottery_predictor/analyze.py +++ b/lottery_predictor/analyze.py @@ -6,9 +6,6 @@ from sqlalchemy import select from data.database import Base, dal, project_variables import util.drawing as drawutil -import util.environment as envutil - -project_variables = envutil.load_environment_variables() def load_dataframe( From 39cd629ff3bc30c0ab25958fd291db8943d17792 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Sun, 8 Mar 2026 19:43:01 -0400 Subject: [PATCH 2/7] Remove pandas import, unneeded --- tests/lottery_predictor/test_analyze.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/lottery_predictor/test_analyze.py b/tests/lottery_predictor/test_analyze.py index 7f6d48f..3e1c78f 100644 --- a/tests/lottery_predictor/test_analyze.py +++ b/tests/lottery_predictor/test_analyze.py @@ -1,6 +1,5 @@ from datetime import datetime import pytest -import pandas as pd import lottery_predictor.analyze as analyze From 7c80122802989d7002f1be01e798840cf080a8bb Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Sun, 8 Mar 2026 19:51:43 -0400 Subject: [PATCH 3/7] Create tests for generate_random_ticket --- tests/lottery_predictor/test_draw.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 tests/lottery_predictor/test_draw.py diff --git a/tests/lottery_predictor/test_draw.py b/tests/lottery_predictor/test_draw.py new file mode 100644 index 0000000..1a7ae6d --- /dev/null +++ b/tests/lottery_predictor/test_draw.py @@ -0,0 +1,10 @@ +import pytest + +import lottery_predictor.draw as draw + + +def test_generate_random_ticket() -> None: + assert isinstance(draw.generate_random_ticket(max_main=69, max_game=26), tuple) + assert isinstance(draw.generate_random_ticket(max_main=70, max_game=24), tuple) + with pytest.raises(TypeError): + draw.generate_random_ticket() From 71263a2a4ccac8eb5f6a74a17c3318bfe30cd587 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Sun, 8 Mar 2026 19:52:11 -0400 Subject: [PATCH 4/7] Create generate_random_ticket --- lottery_predictor/draw.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 lottery_predictor/draw.py diff --git a/lottery_predictor/draw.py b/lottery_predictor/draw.py new file mode 100644 index 0000000..c87c35a --- /dev/null +++ b/lottery_predictor/draw.py @@ -0,0 +1,16 @@ +import random + + +def generate_random_ticket(max_main: int, max_game: int, num_main: int = 5) -> tuple[list[int], int]: + """ + Generate a random lottery ticket. + + :param max_main: The maximum number in the range to choose from for main game balls + :param max_game: The maximum number in the range to choose from for the game ball + :param num_main: The number of numbers that can be chosen in the main field + + :return: A tuple of (main_balls, game_ball) + """ + main_balls = random.sample(range(1, max_main), num_main) + game_ball = random.randint(1, max_game) + return sorted(main_balls), game_ball From 318f2a4ae9174e4730d5d50bc4bff335353ebfad Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Sun, 8 Mar 2026 20:02:18 -0400 Subject: [PATCH 5/7] Add doctstrings to functions --- lottery_predictor/analyze.py | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/lottery_predictor/analyze.py b/lottery_predictor/analyze.py index a871a83..76d1b42 100644 --- a/lottery_predictor/analyze.py +++ b/lottery_predictor/analyze.py @@ -11,7 +11,13 @@ import util.drawing as drawutil def load_dataframe( table_name: str, start_date: datetime | None = None, end_date: datetime | None = None ) -> pd.DataFrame: - """connect to the database and load game data into a pandas dataframe""" + """ + :param table_name: the name of the table to load data from + :param start_date: the start date for the data + :param end_date: the end date for the data + + :returns: a pandas DataFrame containing the data + """ dal.connect() session = dal.Session() @@ -36,10 +42,15 @@ def load_dataframe( def get_most_common_number( - data_frame: pd.DataFrame, - columns: list | None = None, - top: int = 1 + data_frame: pd.DataFrame, columns: list | None = None, top: int = 1 ) -> list[int]: + """ + :param data_frame: a pandas DataFrame containing the data + :param columns: a list of column names to use + :param top: the number of top (most seen) numbers to return + + :returns: a list of the most common numbers + """ if columns is None: columns = ['main_ball1', 'main_ball2', 'main_ball3', 'main_ball4', 'main_ball5'] flat_numbers = data_frame[columns].values.flatten() @@ -48,10 +59,15 @@ def get_most_common_number( def get_least_common_number( - data_frame: pd.DataFrame, - columns: list | None = None, - bottom: int = 1 + data_frame: pd.DataFrame, columns: list | None = None, bottom: int = 1 ) -> list[int]: + """ + :param data_frame: a pandas DataFrame containing the data + :param columns: a list of column names to use + :param bottom: the number of bottom (least seen) numbers to return + + :returns: a list of the least common numbers + """ if columns is None: columns = ['main_ball1', 'main_ball2', 'main_ball3', 'main_ball4', 'main_ball5'] flat_numbers = data_frame[columns].values.flatten() From 98215565a8315296a0c38747062571eb98c2aacf Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Sun, 8 Mar 2026 20:07:47 -0400 Subject: [PATCH 6/7] Correct returns --- lottery_predictor/draw.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lottery_predictor/draw.py b/lottery_predictor/draw.py index c87c35a..b42673d 100644 --- a/lottery_predictor/draw.py +++ b/lottery_predictor/draw.py @@ -9,7 +9,7 @@ def generate_random_ticket(max_main: int, max_game: int, num_main: int = 5) -> t :param max_game: The maximum number in the range to choose from for the game ball :param num_main: The number of numbers that can be chosen in the main field - :return: A tuple of (main_balls, game_ball) + :returns: A tuple of (main_balls, game_ball) """ main_balls = random.sample(range(1, max_main), num_main) game_ball = random.randint(1, max_game) From 2278ff0a12c4d5a35270e15e470aaccd2f63e37e Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Sun, 8 Mar 2026 20:08:18 -0400 Subject: [PATCH 7/7] Add docstrings to functions --- lottery_predictor/collect.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lottery_predictor/collect.py b/lottery_predictor/collect.py index 4fc752f..b6da7d7 100644 --- a/lottery_predictor/collect.py +++ b/lottery_predictor/collect.py @@ -18,7 +18,11 @@ project_variables = envutil.load_environment_variables() def get_record_count(table_name: str) -> int | None: - """get the most recent draw record from the specified table""" + """ + :param table_name: the name of the table to get a count of records from + + :returns: the count of records found in the specified table + """ game_dict = drawutil.check_table_name(table_name=table_name) if game_dict: dal.connect() @@ -30,7 +34,11 @@ def get_record_count(table_name: str) -> int | None: def get_recent_draw_date(table_name: str) -> datetime | None: - """get the most recent draw date from the specified table""" + """ + :param table_name: the name of the table to get the most recent draw date from + + :returns datetime: the most recent draw date, if there is one + """ game_dict = drawutil.check_table_name(table_name=table_name) if game_dict: dal.connect() @@ -42,7 +50,11 @@ def get_recent_draw_date(table_name: str) -> datetime | None: def get_missing_records(table_name: str) -> int: - """collect and insert missing records, returning a count of insertions""" + """ + :param table_name: the name of the table to collect and insert missing records in + + :returns: the number of records inserted into the target table + """ # if the table_name is valid game_dict = drawutil.check_table_name(table_name=table_name) if game_dict: