Skip to content

Commit b2ee921

Browse files
committed
update bindgen 0.36 -> 0.59
1 parent c6a855d commit b2ee921

File tree

6 files changed

+15
-15
lines changed

6 files changed

+15
-15
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ documentation = "https://docs.rs/xgboost"
1010
readme = "README.md"
1111

1212
[dependencies]
13-
xgboost-sys = "0.1.2"
13+
xgboost-sys = { path="./xgboost-sys" }
1414
libc = "0.2"
1515
derive_builder = "0.5"
1616
log = "0.4"

src/booster.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ impl Booster {
178178
for (dmat, dmat_name) in eval_sets {
179179
let margin = bst.predict_margin(dmat)?;
180180
let eval_result = eval_fn(&margin, dmat);
181-
let mut eval_results = dmat_eval_results.entry(eval_name.to_string())
181+
let eval_results = dmat_eval_results.entry(eval_name.to_string())
182182
.or_insert_with(IndexMap::new);
183183
eval_results.insert(dmat_name.to_string(), eval_result);
184184
}
@@ -188,7 +188,7 @@ impl Booster {
188188
let mut eval_dmat_results = BTreeMap::new();
189189
for (dmat_name, eval_results) in &dmat_eval_results {
190190
for (eval_name, result) in eval_results {
191-
let mut dmat_results = eval_dmat_results.entry(eval_name).or_insert_with(BTreeMap::new);
191+
let dmat_results = eval_dmat_results.entry(eval_name).or_insert_with(BTreeMap::new);
192192
dmat_results.insert(dmat_name, result);
193193
}
194194
}
@@ -548,7 +548,7 @@ impl Booster {
548548
let score = metric_parts[1].parse::<f32>()
549549
.unwrap_or_else(|_| panic!("Unable to parse XGBoost metrics output: {}", eval));
550550

551-
let mut metric_map = result.entry(evname.to_string()).or_insert_with(IndexMap::new);
551+
let metric_map = result.entry(evname.to_string()).or_insert_with(IndexMap::new);
552552
metric_map.insert(metric.to_owned(), score);
553553
}
554554
}

src/dmatrix.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::{slice, ffi, ptr, path::Path};
22
use libc::{c_uint, c_float};
33
use std::os::unix::ffi::OsStrExt;
4+
use std::convert::TryInto;
45

56
use xgboost_sys;
67

@@ -123,17 +124,17 @@ impl DMatrix {
123124
/// `data[indptr[i]:indptr[i+1]`.
124125
///
125126
/// If `num_cols` is set to None, number of columns will be inferred from given data.
126-
pub fn from_csr(indptr: &[usize], indices: &[usize], data: &[f32], num_cols: Option<usize>) -> XGBResult<Self> {
127+
pub fn from_csr(indptr: &[u64], indices: &[usize], data: &[f32], num_cols: Option<usize>) -> XGBResult<Self> {
127128
assert_eq!(indices.len(), data.len());
128129
let mut handle = ptr::null_mut();
129130
let indices: Vec<u32> = indices.iter().map(|x| *x as u32).collect();
130131
let num_cols = num_cols.unwrap_or(0); // infer from data if 0
131132
xgb_call!(xgboost_sys::XGDMatrixCreateFromCSREx(indptr.as_ptr(),
132133
indices.as_ptr(),
133134
data.as_ptr(),
134-
indptr.len(),
135-
data.len(),
136-
num_cols,
135+
indptr.len().try_into().unwrap(),
136+
data.len().try_into().unwrap(),
137+
num_cols.try_into().unwrap(),
137138
&mut handle))?;
138139
Ok(DMatrix::new(handle)?)
139140
}
@@ -146,17 +147,17 @@ impl DMatrix {
146147
/// `data[indptr[i]:indptr[i+1]`.
147148
///
148149
/// If `num_rows` is set to None, number of rows will be inferred from given data.
149-
pub fn from_csc(indptr: &[usize], indices: &[usize], data: &[f32], num_rows: Option<usize>) -> XGBResult<Self> {
150+
pub fn from_csc(indptr: &[u64], indices: &[usize], data: &[f32], num_rows: Option<usize>) -> XGBResult<Self> {
150151
assert_eq!(indices.len(), data.len());
151152
let mut handle = ptr::null_mut();
152153
let indices: Vec<u32> = indices.iter().map(|x| *x as u32).collect();
153154
let num_rows = num_rows.unwrap_or(0); // infer from data if 0
154155
xgb_call!(xgboost_sys::XGDMatrixCreateFromCSCEx(indptr.as_ptr(),
155156
indices.as_ptr(),
156157
data.as_ptr(),
157-
indptr.len(),
158-
data.len(),
159-
num_rows,
158+
indptr.len().try_into().unwrap(),
159+
data.len().try_into().unwrap(),
160+
num_rows.try_into().unwrap(),
160161
&mut handle))?;
161162
Ok(DMatrix::new(handle)?)
162163
}

src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl XGBError {
3131
match ret_val {
3232
0 => Ok(()),
3333
-1 => Err(XGBError::from_xgboost()),
34-
_ => panic!(format!("unexpected return value '{}', expected 0 or -1", ret_val)),
34+
_ => panic!("unexpected return value '{}', expected 0 or -1", ret_val),
3535
}
3636
}
3737

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ extern crate libc;
6565
extern crate tempfile;
6666
extern crate indexmap;
6767

68-
#[macro_use]
6968
macro_rules! xgb_call {
7069
($x:expr) => {
7170
XGBError::check_return_value(unsafe { $x })

xgboost-sys/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ readme = "README.md"
1313
libc = "0.2"
1414

1515
[build-dependencies]
16-
bindgen = "0.36"
16+
bindgen = "0.59"

0 commit comments

Comments
 (0)