Skip to content

Commit b515773

Browse files
committed
Removed unneeded method
1 parent e99a9ce commit b515773

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed

lib/xgboost/booster.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def save_config
4444
length = ::FFI::MemoryPointer.new(:uint64)
4545
json_string = ::FFI::MemoryPointer.new(:pointer)
4646
check_call FFI.XGBoosterSaveJsonConfig(handle, length, json_string)
47-
json_string.read_pointer.read_string(read_uint64(length)).force_encoding(Encoding::UTF_8)
47+
json_string.read_pointer.read_string(length.read_uint64).force_encoding(Encoding::UTF_8)
4848
end
4949

5050
def attr(key)
@@ -114,7 +114,7 @@ def predict(data, ntree_limit: nil)
114114
out_len = ::FFI::MemoryPointer.new(:uint64)
115115
out_result = ::FFI::MemoryPointer.new(:pointer)
116116
check_call FFI.XGBoosterPredict(handle, data.handle, 0, ntree_limit, 0, out_len, out_result)
117-
out = out_result.read_pointer.read_array_of_float(read_uint64(out_len))
117+
out = out_result.read_pointer.read_array_of_float(out_len.read_uint64)
118118
num_class = out.size / data.num_row
119119
out = out.each_slice(num_class).to_a if num_class > 1
120120
out
@@ -149,7 +149,7 @@ def num_boosted_rounds
149149
def num_features
150150
features = ::FFI::MemoryPointer.new(:uint64)
151151
check_call FFI.XGBoosterGetNumFeature(handle, features)
152-
read_uint64(features)
152+
features.read_uint64
153153
end
154154

155155
def dump_model(fout, fmap: "", with_stats: false, dump_format: "text")
@@ -182,7 +182,7 @@ def dump(fmap: "", with_stats: false, dump_format: "text")
182182

183183
check_call FFI.XGBoosterDumpModelExWithFeatures(handle, names.size, fnames, ftypes, with_stats ? 1 : 0, dump_format, out_len, out_result)
184184

185-
out_result.read_pointer.get_array_of_string(0, read_uint64(out_len))
185+
out_result.read_pointer.get_array_of_string(0, out_len.read_uint64)
186186
end
187187

188188
def fscore(fmap: "")

lib/xgboost/dmatrix.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,25 +92,25 @@ def weight
9292
def num_row
9393
out = ::FFI::MemoryPointer.new(:uint64)
9494
check_call FFI.XGDMatrixNumRow(handle, out)
95-
read_uint64(out)
95+
out.read_uint64
9696
end
9797

9898
def num_col
9999
out = ::FFI::MemoryPointer.new(:uint64)
100100
check_call FFI.XGDMatrixNumCol(handle, out)
101-
read_uint64(out)
101+
out.read_uint64
102102
end
103103

104104
def num_nonmissing
105105
out = ::FFI::MemoryPointer.new(:uint64)
106106
check_call FFI.XGDMatrixNumNonMissing(handle, out)
107-
read_uint64(out)
107+
out.read_uint64
108108
end
109109

110110
def data_split_mode
111111
out = ::FFI::MemoryPointer.new(:uint64)
112112
check_call FFI.XGDMatrixDataSplitMode(handle, out)
113-
read_uint64(out) == 0 ? :row : :col
113+
out.read_uint64 == 0 ? :row : :col
114114
end
115115

116116
def slice(rindex)

lib/xgboost/utils.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,10 @@ def string_pointer(value)
2424

2525
def from_cstr_to_rbstr(data, length)
2626
res = []
27-
read_uint64(length).times do |i|
27+
length.read_uint64.times do |i|
2828
res << data.read_pointer[i * ::FFI::Pointer.size].read_pointer.read_string.force_encoding(Encoding::UTF_8)
2929
end
3030
res
3131
end
32-
33-
# read_uint64 not available on JRuby
34-
def read_uint64(ptr)
35-
ptr.read_array_of_uint64(1).first
36-
end
3732
end
3833
end

0 commit comments

Comments
 (0)