Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[python-package] add more type hints on Booster #5432

Merged
merged 1 commit into from
Aug 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions python-package/lightgbm/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2760,7 +2760,7 @@ def __deepcopy__(self, _) -> "Booster":
booster = Booster(model_str=model_str)
return booster

def __getstate__(self):
def __getstate__(self) -> Dict[str, Any]:
this = self.__dict__.copy()
handle = this['handle']
this.pop('train_set', None)
Expand All @@ -2769,7 +2769,7 @@ def __getstate__(self):
this["handle"] = self.model_to_string(num_iteration=-1)
return this

def __setstate__(self, state):
def __setstate__(self, state: Dict[str, Any]) -> None:
model_str = state.get('handle', None)
if model_str is not None:
handle = ctypes.c_void_p()
Expand Down Expand Up @@ -3663,16 +3663,16 @@ def refit(
self,
data,
label,
decay_rate=0.9,
reference=None,
decay_rate: float = 0.9,
reference: Optional[Dataset] = None,
weight=None,
group=None,
init_score=None,
feature_name='auto',
categorical_feature='auto',
dataset_params=None,
free_raw_data=True,
validate_features=False,
feature_name: Union[str, List[str]] = 'auto',
categorical_feature: Union[str, List[str], List[int]] = 'auto',
dataset_params: Optional[Dict[str, Any]] = None,
free_raw_data: bool = True,
validate_features: bool = False,
**kwargs
):
"""Refit the existing Booster by new data.
Expand Down