tests/testthat/test_multithreading.R

test_that("getLGBMthreads() and setLGBMthreads() work as expected", {
    # works with integer input
    ret <- setLGBMthreads(2L)
    expect_null(ret)
    expect_equal(getLGBMthreads(), 2L)

    # works with float input
    ret <- setLGBMthreads(1.0)
    expect_null(ret)
    expect_equal(getLGBMthreads(), 1L)

    # setting to any negative number sets max threads to -1
    ret <- setLGBMthreads(-312L)
    expect_null(ret)
    expect_equal(getLGBMthreads(), -1L)
})

Try the lightgbm package in your browser

Any scripts or data that you put into this service are public.

lightgbm documentation built on Sept. 11, 2024, 8:44 p.m.