Skip to content

Commit

Permalink
[python-package] add more type hints (#5694)
Browse files Browse the repository at this point in the history
  • Loading branch information
jameslamb authored Feb 12, 2023
1 parent e4dc238 commit 814a01e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions python-package/lightgbm/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def _is_numpy_column_array(data: Any) -> bool:
return len(shape) == 2 and shape[1] == 1


def _cast_numpy_array_to_dtype(array, dtype):
def _cast_numpy_array_to_dtype(array: np.ndarray, dtype: np.dtype) -> np.ndarray:
"""Cast numpy array to given dtype."""
if array.dtype == dtype:
return array
Expand Down Expand Up @@ -514,7 +514,7 @@ def _choose_param_value(main_param_name: str, params: Dict[str, Any], default_va
}


def _convert_from_sliced_object(data):
def _convert_from_sliced_object(data: np.ndarray) -> np.ndarray:
"""Fix the memory of multi-dimensional sliced object."""
if isinstance(data, np.ndarray) and isinstance(data.base, np.ndarray):
if not data.flags.c_contiguous:
Expand Down Expand Up @@ -564,7 +564,7 @@ def _c_int_array(data):
return (ptr_data, type_data, data) # return `data` to avoid the temporary copy is freed


def _check_for_bad_pandas_dtypes(pandas_dtypes_series):
def _check_for_bad_pandas_dtypes(pandas_dtypes_series: pd_Series) -> None:
float128 = getattr(np, 'float128', type(None))

def is_allowed_numpy_dtype(dtype):
Expand Down

0 comments on commit 814a01e

Please sign in to comment.