Copilot commented on code in PR #50929:
URL: https://github.com/apache/arrow/pull/50929#discussion_r3904072245


##########
cpp/src/arrow/c/dlpack.cc:
##########
@@ -35,34 +35,24 @@ namespace arrow::dlpack {
 namespace {
 
 Result<DLDataType> GetDLDataType(const DataType& type) {
-  DLDataType dtype;
+  auto dtype = DLDataType{};
   dtype.lanes = 1;
   dtype.bits = type.bit_width();
-  switch (type.id()) {
-    case Type::INT8:
-    case Type::INT16:
-    case Type::INT32:
-    case Type::INT64:
-      dtype.code = DLDataTypeCode::kDLInt;
-      return dtype;
-    case Type::UINT8:
-    case Type::UINT16:
-    case Type::UINT32:
-    case Type::UINT64:
-      dtype.code = DLDataTypeCode::kDLUInt;
-      return dtype;
-    case Type::HALF_FLOAT:
-    case Type::FLOAT:
-    case Type::DOUBLE:
-      dtype.code = DLDataTypeCode::kDLFloat;
-      return dtype;
-    case Type::BOOL:
-      // DLPack supports byte-packed boolean values
-      return Status::TypeError("Bit-packed boolean data type not supported by 
DLPack.");
-    default:
-      return Status::TypeError("DataType is not compatible with DLPack spec: ",
-                               type.ToString());
+  if (is_signed_integer(type.id())) {
+    dtype.code = DLDataTypeCode::kDLInt;
+  } else if (is_unsigned_integer(type.id())) {
+    dtype.code = DLDataTypeCode::kDLUInt;
+  } else if (is_floating(type.id())) {
+    dtype.code = DLDataTypeCode::kDLFloat;
+  } else if (type.id() == Type::BOOL) {
+    // DLPack supports byte-packed boolean values
+    return Status::TypeError("Bit-packed boolean data type not supported by 
DLPack.");
+  } else {
+    return Status::TypeError(
+        "DataType is not compatible with DLPack spec: ", type.ToString(),
+        ", try converting to a Tensor for multi dimensional data support");

Review Comment:
   The new TypeError message says "multi dimensional"; for a user-facing error 
string this reads like a typo/grammar issue. Consider changing to 
"multidimensional" or "multi-dimensional" (and update the matching expectations 
in dlpack_test.cc accordingly).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to