rok commented on code in PR #40365:
URL: https://github.com/apache/arrow/pull/40365#discussion_r1514625034


##########
cpp/src/arrow/testing/gtest_util.h:
##########
@@ -354,6 +354,13 @@ ARROW_TESTING_EXPORT
 std::shared_ptr<Table> TableFromJSON(const std::shared_ptr<Schema>&,
                                      const std::vector<std::string>& json);
 
+ARROW_TESTING_EXPORT
+std::shared_ptr<Tensor> TensorFromJSON(const std::shared_ptr<DataType>& type,
+                                       const std::vector<int64_t>& shape,
+                                       std::string_view json,
+                                       const std::vector<int64_t>& strides = 
{},
+                                       const std::vector<std::string>& 
dim_names = {});

Review Comment:
   How about allowing `shape`, `dim_names` and `strides` be input as JSON as 
well?
   ```suggestion
   ARROW_TESTING_EXPORT
   std::shared_ptr<Tensor> TensorFromJSON(const std::shared_ptr<DataType>& type,
                                          std::string_view data,
                                          std::string_view shape,
                                          std::string_view dim_names = "[]",
                                          std::string_view strides = "[]");
   ```
   
   Small nit, make argument order equal to `Tensor::Make`:
   ```cpp
     static inline Result<std::shared_ptr<Tensor>> Make(
         const std::shared_ptr<DataType>& type, const std::shared_ptr<Buffer>& 
data,
         const std::vector<int64_t>& shape, const std::vector<int64_t>& strides 
= {},
         const std::vector<std::string>& dim_names = {}) {
   ```



-- 
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