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
434573ee
"...git@developer.sourcefind.cn:tianlh/lightgbm-dcu.git" did not exist on "170a93044bf7c8c3d90d64b4ceeb21d3c8bf1fbb"
Unverified
Commit
434573ee
authored
Apr 15, 2021
by
Roman Grebennikov
Committed by
GitHub
Apr 15, 2021
Browse files
[swig] add wrapper for LGBM_DatasetGetFeatureNames (#4103)
parent
98e5a210
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
0 deletions
+40
-0
swig/StringArray_API_extensions.i
swig/StringArray_API_extensions.i
+40
-0
No files found.
swig/StringArray_API_extensions.i
View file @
434573ee
...
...
@@ -104,4 +104,44 @@
return
strings
.
release
()
;
}
/**
* @brief Wraps LGBM_DatasetGetFeatureNames. Has the same limitations as a
* LGBM_BoosterGetFeatureNames:
*
* Allocates a new StringArray. You must free it yourself if it succeeds.
* @see StringArrayHandle_free().
* In case of failure such resource is freed and nullptr is returned.
* Check for that case with null (lightgbmlib) or 0 (lightgbmlibJNI).
*
* @param handle Booster handle
* @return StringArrayHandle with the feature names (or nullptr in case of error)
*/
StringArrayHandle
LGBM_DatasetGetFeatureNamesSWIG
(
BoosterHandle
handle
)
{
int
num_features
;
size_t
max_feature_name_size
;
std
::
unique_ptr
<
StringArray
>
strings
(
nullptr
)
;
// Retrieve required allocation space:
API_OK_OR_NULL
(
LGBM_DatasetGetFeatureNames
(
handle
,
0
,
&
num_features,
0
,
&
max_feature_name_size,
nullptr
))
;
try
{
strings
.
reset
(
new
StringArray
(
num_features
,
max_feature_name_size
))
;
}
catch
(
std
::
bad_alloc
&
e)
{
LGBM_SetLastError
(
"Failure to allocate memory."
)
;
return
nullptr
;
}
API_OK_OR_NULL
(
LGBM_DatasetGetFeatureNames
(
handle
,
num_features
,
&
num_features,
max_feature_name_size
,
&
max_feature_name_size,
strings-
>
data
()))
;
return
strings
.
release
()
;
}
%
}
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