Skip to content

Commit defb6d1

Browse files
committed
add float16 into tests
1 parent 0bec672 commit defb6d1

3 files changed

Lines changed: 5 additions & 4 deletions

File tree

r/src/r_to_arrow.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <arrow/util/bitmap_writer.h>
3030
#include <arrow/util/checked_cast.h>
3131
#include <arrow/util/converter.h>
32+
#include <arrow/util/float16.h>
3233
#include <arrow/util/logging.h>
3334

3435
#include "./r_task_group.h"
@@ -390,12 +391,12 @@ struct RConvert {
390391
return static_cast<float>(from);
391392
}
392393

393-
// ---- convert to half float: not implemented
394+
// ---- convert to half float
394395
template <typename Type, typename From>
395396
static enable_if_t<std::is_same<Type, const HalfFloatType>::value,
396397
Result<typename Type::c_type>>
397398
Convert(Type*, From from) {
398-
return Status::Invalid("Cannot convert to Half Float");
399+
return arrow::util::Float16(static_cast<double>(from)).bits();
399400
}
400401
};
401402

r/tests/testthat/test-chunked-array.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
int_types <- c(int8(), int16(), int32(), int64())
1919
uint_types <- c(uint8(), uint16(), uint32(), uint64())
20-
float_types <- c(float32(), float64()) # float16() not really supported in C++ yet
20+
float_types <- c(float16(), float32(), float64())
2121
all_numeric_types <- c(int_types, uint_types, float_types)
2222

2323
expect_chunked_roundtrip <- function(x, type) {

r/tests/testthat/test-dplyr-funcs-type.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ test_that("explicit type conversions with cast()", {
3131

3232
int_types <- c(int8(), int16(), int32(), int64())
3333
uint_types <- c(uint8(), uint16(), uint32(), uint64())
34-
float_types <- c(float32(), float64())
34+
float_types <- c(float16(), float32(), float64())
3535

3636
types <- c(
3737
int_types,

0 commit comments

Comments
 (0)