From b71e04fb4ce0e6caa2d5d0f469f354f3e043f83c Mon Sep 17 00:00:00 2001 From: James Lamb Date: Fri, 29 Sep 2023 19:20:23 -0500 Subject: [PATCH 1/2] [python-package] simplify Dataset._compare_params_for_warning() --- python-package/lightgbm/basic.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/python-package/lightgbm/basic.py b/python-package/lightgbm/basic.py index 3dfa583a62bb..6e61ec184556 100644 --- a/python-package/lightgbm/basic.py +++ b/python-package/lightgbm/basic.py @@ -2200,8 +2200,8 @@ def __init_from_csc( @staticmethod def _compare_params_for_warning( - params: Optional[Dict[str, Any]], - other_params: Optional[Dict[str, Any]], + params: Dict[str, Any], + other_params: Dict[str, Any], ignore_keys: Set[str] ) -> bool: """Compare two dictionaries with params ignoring some keys. @@ -2222,10 +2222,6 @@ def _compare_params_for_warning( compare_result : bool Returns whether two dictionaries with params are equal. """ - if params is None: - params = {} - if other_params is None: - other_params = {} for k in other_params: if k not in ignore_keys: if k not in params or params[k] != other_params[k]: From 63c38c048cba0af967dd52e668134c356e6e07e6 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Mon, 2 Oct 2023 15:14:19 -0500 Subject: [PATCH 2/2] update docstring --- python-package/lightgbm/basic.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python-package/lightgbm/basic.py b/python-package/lightgbm/basic.py index 6e61ec184556..9b833afada84 100644 --- a/python-package/lightgbm/basic.py +++ b/python-package/lightgbm/basic.py @@ -2210,9 +2210,9 @@ def _compare_params_for_warning( Parameters ---------- - params : dict or None + params : dict One dictionary with parameters to compare. - other_params : dict or None + other_params : dict Another dictionary with parameters to compare. ignore_keys : set Keys that should be ignored during comparing two dictionaries.