Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
t-kalinowski committed Jun 18, 2024
1 parent bc2d4c7 commit 4091c87
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/testthat/test-python-arrays.R
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,20 @@ def apply_mask(x, mask):
}

})


test_that("StringDtype arrays convert correctly", {

np <- import("numpy", convert = FALSE)

StringDType <- py_get_attr(np$dtypes, "StringDType", TRUE)
if(is.null(StringDType))
skip("No NumPy StringDType (numpy<2.0)")

data <- c("this is a longer string", "short string")

x <- np$array(data, dtype=StringDType())
expect_true(startsWith(py_to_r(x$dtype$name), "StringDType"))

expect_identical(py_to_r(x), array(data))
})

0 comments on commit 4091c87

Please sign in to comment.