Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tianlh
LightGBM-DCU
Commits
6b695c29
Unverified
Commit
6b695c29
authored
Aug 15, 2022
by
Akshita Prasanth
Committed by
GitHub
Aug 15, 2022
Browse files
[python] Prefix `basic.is_numeric()` with _ (#5421)
parent
5ef46f93
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
python-package/lightgbm/basic.py
python-package/lightgbm/basic.py
+3
-3
No files found.
python-package/lightgbm/basic.py
View file @
6b695c29
...
@@ -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__
}
'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment