Copilot commented on code in PR #50203:
URL: https://github.com/apache/arrow/pull/50203#discussion_r3477567221
##########
python/pyarrow/src/arrow/python/python_to_arrow.cc:
##########
@@ -908,13 +908,30 @@ class PyListConverter : public ListConverter<T,
PyConverter, PyConverterTrait> {
Status AppendNdarray(PyObject* value) {
PyArrayObject* ndarray = reinterpret_cast<PyArrayObject*>(value);
- if (PyArray_NDIM(ndarray) != 1) {
- return Status::Invalid("Can only convert 1-dimensional array values");
- }
if (PyArray_ISBYTESWAPPED(ndarray)) {
// TODO
return Status::NotImplemented("Byte-swapped arrays not supported");
}
+ OwnedRef flattened;
+ if (PyArray_NDIM(ndarray) != 1) {
+ // GH-49644: a fixed-size list (e.g. fixed-shape-tensor storage) is built
+ // from a multi- or 0-dimensional array by flattening it in C order.
+ if (this->list_type_->id() != Type::FIXED_SIZE_LIST) {
+ return Status::Invalid("Can only convert 1-dimensional array values of
",
+ this->list_type_->ToString(), " to a
variable-sized list");
+ }
Review Comment:
The Invalid-status message for non-fixed-size lists is awkward and
misleading (it says “array values of <list type> to a variable-sized list”).
Since `list_type_->ToString()` already describes the target list type, rephrase
the message to clearly indicate what can be converted and to what type.
--
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]