Skip to content

Commit 58e25e1

Browse files
committed
Add uint64 example
1 parent 235e848 commit 58e25e1

4 files changed

Lines changed: 23 additions & 2 deletions

File tree

inst/scripts/generate_test_data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
# Unsigned integer (stored as integer in R)
1111
np.save("inst/extdata/test_uint8.npy", np.array([0, 10, 20, 50, 100, 128, 150, 175, 200, 210, 240, 255], dtype="uint8"))
1212
np.save("inst/extdata/test_uint16.npy", np.array([0, 100, 1000, 5000, 10000, 20000, 32767, 40000, 50000, 55000, 60000, 65535], dtype="uint16"))
13-
np.save("inst/extdata/test_uint32.npy", np.array([0, 1, 10, 100, 1000, 10000, 100000, 1000000, 2**16, 2**24, 2**31, 2**32 - 1], dtype="uint32"))
14-
np.save("inst/extdata/test_uint64.npy", np.array([0, 1, 10, 100, 1000, 10000, 100000, 2**16, 2**32, 2**48, 2**63, 2**64 - 1], dtype="uint64"))
13+
np.save("inst/extdata/test_uint32_overflowing.npy", np.array([0, 1, 10, 100, 1000, 10000, 100000, 1000000, 2**16, 2**24, 2**31, 2**32 - 1], dtype="uint32"))
14+
np.save("inst/extdata/test_uint64_overflowing.npy", np.array([0, 1, 10, 100, 1000, 10000, 100000, 2**16, 2**32, 2**48, 2**63, 2**64 - 1], dtype="uint64"))
1515

1616
# Float types
1717
np.save("inst/extdata/test_float32.npy", np.array([1.5, -2.5, 3.14, 0.0, -1.0, 100.0, -100.0, 0.001, 1e6, -1e6, 1.23456, -9.87654], dtype="float32"))

tests/testthat/test-read_npy.R

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,27 @@ test_that("different types work", {
8888
)) |>
8989
expect_warning("overflow")
9090

91+
system.file("extdata", "test_uint64_overflowing.npy", package = "grumpy") |>
92+
read_npy() |>
93+
expect_identical(array(
94+
c(
95+
0L,
96+
1L,
97+
10L,
98+
100L,
99+
1000L,
100+
10000L,
101+
100000L,
102+
65536L,
103+
NA_integer_,
104+
NA_integer_,
105+
NA_integer_,
106+
NA_integer_
107+
),
108+
dim = 12L
109+
)) |>
110+
expect_warning("overflow")
111+
91112
system.file("extdata", "test_float32.npy", package = "grumpy") |>
92113
read_npy() |>
93114
expect_no_condition() |>

0 commit comments

Comments
 (0)