Unverified Commit 6b695c29 authored by Akshita Prasanth's avatar Akshita Prasanth Committed by GitHub
Browse files

[python] Prefix `basic.is_numeric()` with _ (#5421)

parent 5ef46f93
...@@ -156,7 +156,7 @@ def _safe_call(ret: int) -> None: ...@@ -156,7 +156,7 @@ def _safe_call(ret: int) -> None:
raise LightGBMError(_LIB.LGBM_GetLastError().decode('utf-8')) 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.""" """Check whether object is a number or not, include numpy number, etc."""
try: try:
float(obj) float(obj)
...@@ -189,7 +189,7 @@ def cast_numpy_array_to_dtype(array, dtype): ...@@ -189,7 +189,7 @@ def cast_numpy_array_to_dtype(array, dtype):
def is_1d_list(data: Any) -> bool: def is_1d_list(data: Any) -> bool:
"""Check whether data is a 1-D list.""" """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: def _is_1d_collection(data: Any) -> bool:
...@@ -317,7 +317,7 @@ def param_dict_to_str(data: Optional[Dict[str, Any]]) -> str: ...@@ -317,7 +317,7 @@ def param_dict_to_str(data: Optional[Dict[str, Any]]) -> str:
else: else:
return str(x) return str(x)
pairs.append(f"{key}={','.join(map(to_string, val))}") 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}") pairs.append(f"{key}={val}")
elif val is not None: elif val is not None:
raise TypeError(f'Unknown type of parameter:{key}, got:{type(val).__name__}') raise TypeError(f'Unknown type of parameter:{key}, got:{type(val).__name__}')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment