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
8c335352
Unverified
Commit
8c335352
authored
Apr 12, 2020
by
OMOTO Tsukasa
Committed by
GitHub
Apr 12, 2020
Browse files
Fix user locale settings (#2980)
This reverts commit
6b68967d
(#2891) and fixes #2979.
parent
44a91201
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
46 deletions
+0
-46
include/LightGBM/utils/locale_context.h
include/LightGBM/utils/locale_context.h
+0
-40
src/c_api.cpp
src/c_api.cpp
+0
-6
No files found.
include/LightGBM/utils/locale_context.h
deleted
100644 → 0
View file @
44a91201
/*!
* Copyright (c) 2020 Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See LICENSE file in the project root for license information.
*/
#ifndef LIGHTGBM_LOCALE_CONTEXT_H_
#define LIGHTGBM_LOCALE_CONTEXT_H_
#include <clocale>
#include <locale>
/*!
* Class to override the program global locale during this object lifetime.
* After the object is destroyed, the locale is returned to its original state.
*
* @warn This is not thread-safe.
*/
class
LocaleContext
{
public:
/*!
* Override the current program global locale during this object lifetime.
*
* @param target_locale override the locale to this locale setting.
* @warn This is not thread-safe.
* @note This doesn't override cout, cerr, etc.
*/
explicit
LocaleContext
(
const
char
*
target_locale
=
"C"
)
{
std
::
locale
::
global
(
std
::
locale
(
target_locale
));
}
/*!
* Restores the old global locale.
*/
~
LocaleContext
()
{
std
::
locale
::
global
(
_saved_global_locale
);
}
private:
std
::
locale
_saved_global_locale
;
//!< Stores global locale at initialization.
};
#endif // LIGHTGBM_LOCALE_CONTEXT_H_
src/c_api.cpp
View file @
8c335352
...
...
@@ -13,7 +13,6 @@
#include <LightGBM/objective_function.h>
#include <LightGBM/prediction_early_stop.h>
#include <LightGBM/utils/common.h>
#include <LightGBM/utils/locale_context.h>
#include <LightGBM/utils/log.h>
#include <LightGBM/utils/openmp_wrapper.h>
#include <LightGBM/utils/random.h>
...
...
@@ -1237,7 +1236,6 @@ int LGBM_BoosterCreateFromModelfile(
int
*
out_num_iterations
,
BoosterHandle
*
out
)
{
API_BEGIN
();
LocaleContext
withLocaleContext
(
"C"
);
auto
ret
=
std
::
unique_ptr
<
Booster
>
(
new
Booster
(
filename
));
*
out_num_iterations
=
ret
->
GetBoosting
()
->
GetCurrentIteration
();
*
out
=
ret
.
release
();
...
...
@@ -1249,7 +1247,6 @@ int LGBM_BoosterLoadModelFromString(
int
*
out_num_iterations
,
BoosterHandle
*
out
)
{
API_BEGIN
();
LocaleContext
withLocaleContext
(
"C"
);
auto
ret
=
std
::
unique_ptr
<
Booster
>
(
new
Booster
(
nullptr
));
ret
->
LoadModelFromString
(
model_str
);
*
out_num_iterations
=
ret
->
GetBoosting
()
->
GetCurrentIteration
();
...
...
@@ -1674,7 +1671,6 @@ int LGBM_BoosterSaveModel(BoosterHandle handle,
int
num_iteration
,
const
char
*
filename
)
{
API_BEGIN
();
LocaleContext
withLocaleContext
(
"C"
);
Booster
*
ref_booster
=
reinterpret_cast
<
Booster
*>
(
handle
);
ref_booster
->
SaveModelToFile
(
start_iteration
,
num_iteration
,
filename
);
API_END
();
...
...
@@ -1687,7 +1683,6 @@ int LGBM_BoosterSaveModelToString(BoosterHandle handle,
int64_t
*
out_len
,
char
*
out_str
)
{
API_BEGIN
();
LocaleContext
withLocaleContext
(
"C"
);
Booster
*
ref_booster
=
reinterpret_cast
<
Booster
*>
(
handle
);
std
::
string
model
=
ref_booster
->
SaveModelToString
(
start_iteration
,
num_iteration
);
*
out_len
=
static_cast
<
int64_t
>
(
model
.
size
())
+
1
;
...
...
@@ -1704,7 +1699,6 @@ int LGBM_BoosterDumpModel(BoosterHandle handle,
int64_t
*
out_len
,
char
*
out_str
)
{
API_BEGIN
();
LocaleContext
withLocaleContext
(
"C"
);
Booster
*
ref_booster
=
reinterpret_cast
<
Booster
*>
(
handle
);
std
::
string
model
=
ref_booster
->
DumpModel
(
start_iteration
,
num_iteration
);
*
out_len
=
static_cast
<
int64_t
>
(
model
.
size
())
+
1
;
...
...
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