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] Prefix basic.is_numeric() with _ #5421

Merged
merged 1 commit into from
Aug 15, 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
6 changes: 3 additions & 3 deletions python-package/lightgbm/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def _safe_call(ret: int) -> None:
raise LightGBMError(_LIB.LGBM_GetLastError().decode('utf-8'))


def is_numeric(obj: Any) -> bool:
def _is_numeric(obj: Any) -> bool:
"""Check whether object is a number or not, include numpy number, etc."""
try:
float(obj)
Expand Down Expand Up @@ -189,7 +189,7 @@ def cast_numpy_array_to_dtype(array, dtype):

def is_1d_list(data: Any) -> bool:
"""Check whether data is a 1-D list."""
return isinstance(data, list) and (not data or is_numeric(data[0]))
return isinstance(data, list) and (not data or _is_numeric(data[0]))


def _is_1d_collection(data: Any) -> bool:
Expand Down Expand Up @@ -317,7 +317,7 @@ def to_string(x):
else:
return str(x)
pairs.append(f"{key}={','.join(map(to_string, val))}")
elif isinstance(val, (str, Path, _NUMERIC_TYPES)) or is_numeric(val):
elif isinstance(val, (str, Path, _NUMERIC_TYPES)) or _is_numeric(val):
pairs.append(f"{key}={val}")
elif val is not None:
raise TypeError(f'Unknown type of parameter:{key}, got:{type(val).__name__}')
Expand Down