-
Notifications
You must be signed in to change notification settings - Fork 3.7k
GH-46611: [Python][C++] Allow building float16 arrays without numpy #46618
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
5c0b2d1
833fb20
fea6b8e
c0cca40
1fe86f9
e56e6ec
a84fffe
53b8657
566fe4f
ae27eef
619b628
4624274
74eedf6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,9 +26,8 @@ | |
|
||
#include "arrow/python/numpy_interop.h" | ||
|
||
#include <numpy/halffloat.h> | ||
|
||
#include "arrow/type_fwd.h" | ||
#include "arrow/util/float16.h" | ||
#include "arrow/util/logging.h" | ||
|
||
namespace arrow { | ||
|
@@ -87,15 +86,18 @@ NPY_INT_DECL(ULONGLONG, UInt64, uint64_t); | |
|
||
template <> | ||
struct npy_traits<NPY_FLOAT16> { | ||
typedef npy_half value_type; | ||
typedef uint16_t value_type; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note this could also be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is requiring quite a lot of changes around |
||
using TypeClass = HalfFloatType; | ||
using BuilderClass = HalfFloatBuilder; | ||
|
||
static constexpr npy_half na_sentinel = NPY_HALF_NAN; | ||
static constexpr uint16_t na_sentinel = | ||
std::numeric_limits<arrow::util::Float16>::quiet_NaN().bits(); | ||
|
||
static constexpr bool supports_nulls = true; | ||
|
||
static inline bool isnull(npy_half v) { return v == NPY_HALF_NAN; } | ||
static inline bool isnull(uint16_t v) { | ||
return arrow::util::Float16::FromBits(v).is_nan(); | ||
} | ||
}; | ||
|
||
template <> | ||
|
@@ -201,7 +203,8 @@ template <> | |
struct arrow_traits<Type::HALF_FLOAT> { | ||
static constexpr int npy_type = NPY_FLOAT16; | ||
static constexpr bool supports_nulls = true; | ||
static constexpr uint16_t na_value = NPY_HALF_NAN; | ||
static constexpr uint16_t na_value = | ||
std::numeric_limits<arrow::util::Float16>::quiet_NaN().bits(); | ||
typedef typename npy_traits<NPY_FLOAT16>::value_type T; | ||
}; | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.