Skip to content

Commit f831baf

Browse files
committed
Keep missing endian to NA
1 parent 118a992 commit f831baf

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

R/read_npy.R

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ parse_npy_datatype <- function(descr) {
113113
regexec("^([<>|]?)([a-zA-Z])([0-9]*)$", descr)
114114
)[[1L]]
115115
endianness <- if (descr_components[2L] %in% c("", "|")) {
116-
.Platform$endian
116+
NA_character_
117117
} else {
118118
switch(
119119
descr_components[2L],
@@ -198,8 +198,13 @@ parse_npy_data <- function(bytes, shape, datatype, typesize, endian) {
198198
)
199199
}
200200
} else {
201+
endian <- if (is.na(endian)) {
202+
.Platform$endian
203+
} else {
204+
endian
205+
}
201206
# FIXME: optimize this
202-
if (datatype != "unicode" && !is.na(endian) && endian != .Platform$endian) {
207+
if (datatype != "unicode" && endian != .Platform$endian) {
203208
ind <- rep_len(rev(seq_len(typesize)), length(bytes)) +
204209
(seq_along(bytes) - 1L) %/% typesize * typesize
205210
bytes <- bytes[ind]

0 commit comments

Comments
 (0)