Skip to content

Commit

Permalink
hack: make xgboost test finish quicker
Browse files Browse the repository at this point in the history
  • Loading branch information
MarWeUMR committed Oct 7, 2022
1 parent 325ca07 commit 99d755a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 53 deletions.
51 changes: 0 additions & 51 deletions operators/src/pro/ml/bindings/dmatrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,57 +16,6 @@ static KEY_BASE_MARGIN: &str = "base_margin";
///
/// It's used as a container for both features (i.e. a row for every instance), and an optional true label for that
/// instance (as an `f32` value).
///
/// Can be created files, or from dense or sparse
/// ([CSR](https://en.wikipedia.org/wiki/Sparse_matrix#Compressed_sparse_row_(CSR,_CRS_or_Yale_format))
/// or [CSC](https://en.wikipedia.org/wiki/Sparse_matrix#Compressed_sparse_column_(CSC_or_CCS))) matrices.
///
/// # Examples
///
/// ## Load from file
///
/// Load matrix from file in [LIBSVM](https://www.csie.ntu.edu.tw/~cjlin/libsvm/) or binary format.
///
/// ```should_panic
/// use geoengine_operators::pro::ml::bindings::DMatrix;
///
/// let dmat = DMatrix::load("somefile.txt").unwrap();
/// ```
///
/// ## Create from dense array
///
/// ```
/// use geoengine_operators::pro::ml::bindings::DMatrix;
///
/// let data = &[1.0, 0.5, 0.2, 0.2,
/// 0.7, 1.0, 0.1, 0.1,
/// 0.2, 0.0, 0.0, 1.0];
/// let num_rows = 3;
/// let mut dmat = DMatrix::from_dense(data, num_rows).unwrap();
/// assert_eq!(dmat.shape(), (3, 4));
///
/// // set true labels for each row
/// dmat.set_labels(&[1.0, 0.0, 1.0]);
/// ```
///
/// ## Create from sparse CSR matrix
///
/// Create from sparse representation of
/// ```text
/// [[1.0, 0.0, 2.0],
/// [0.0, 0.0, 3.0],
/// [4.0, 5.0, 6.0]]
/// ```
///
/// ```
/// use geoengine_operators::pro::ml::bindings::DMatrix;
///
/// let indptr = &[0, 2, 3, 6];
/// let indices = &[0, 2, 2, 0, 1, 2];
/// let data = &[1.0, 2.0, 3.0, 4.0, 5.0, 6.0];
/// let dmat = DMatrix::from_csr(indptr, indices, data, None).unwrap();
/// assert_eq!(dmat.shape(), (3, 0));
/// ```
#[derive(Debug)]
pub struct DMatrix {
pub(super) handle: xgboost_sys::DMatrixHandle,
Expand Down
10 changes: 8 additions & 2 deletions operators/src/pro/ml/xgboost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,8 @@ mod tests {

#[tokio::test]
async fn xg_op_test() {
// TODO: This test needs a much smaller test data set.

// setup data to predict
let paths = vec![
"s2_10m_de_marburg/b02.tiff",
Expand Down Expand Up @@ -535,11 +537,15 @@ mod tests {

let ctx = MockQueryContext::test_default();
let result_stream = processor.query(qry_rectangle, &ctx).await.unwrap();
let result: Vec<crate::util::Result<RasterTile2D<f32>>> = result_stream.collect().await;

// TODO: .take(1) for a quick test run
let result: Vec<crate::util::Result<RasterTile2D<f32>>> =
result_stream.take(1).collect().await;

let mut all_pixels = Vec::new();

for tile in result {
// TODO: .take(1) for a quick test run
for tile in result.into_iter().take(1) {
let data_of_tile = tile
.unwrap()
.into_materialized_tile()
Expand Down

0 comments on commit 99d755a

Please sign in to comment.