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-package] prefix basic.convert_from_sliced_object with _ #5613

Merged
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 @@ -501,7 +501,7 @@ def _choose_param_value(main_param_name: str, params: Dict[str, Any], default_va
"gain": C_API_FEATURE_IMPORTANCE_GAIN}


def convert_from_sliced_object(data):
def _convert_from_sliced_object(data):
"""Fix the memory of multi-dimensional sliced object."""
if isinstance(data, np.ndarray) and isinstance(data.base, np.ndarray):
if not data.flags.c_contiguous:
Expand All @@ -516,7 +516,7 @@ def c_float_array(data):
if _is_1d_list(data):
data = np.array(data, copy=False)
if _is_numpy_1d_array(data):
data = convert_from_sliced_object(data)
data = _convert_from_sliced_object(data)
assert data.flags.c_contiguous
if data.dtype == np.float32:
ptr_data = data.ctypes.data_as(ctypes.POINTER(ctypes.c_float))
Expand All @@ -536,7 +536,7 @@ def c_int_array(data):
if _is_1d_list(data):
data = np.array(data, copy=False)
if _is_numpy_1d_array(data):
data = convert_from_sliced_object(data)
data = _convert_from_sliced_object(data)
assert data.flags.c_contiguous
if data.dtype == np.int32:
ptr_data = data.ctypes.data_as(ctypes.POINTER(ctypes.c_int32))
Expand Down