You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "AlenkaF (via GitHub)" <gi...@apache.org> on 2023/09/27 06:41:56 UTC

[GitHub] [arrow] AlenkaF commented on a diff in pull request #36496: GH-35623: [C++][Python] FixedShapeTensorType.ToString() should print the type's parameters

AlenkaF commented on code in PR #36496:
URL: https://github.com/apache/arrow/pull/36496#discussion_r1338111961


##########
cpp/src/arrow/extension/fixed_shape_tensor.cc:
##########
@@ -104,6 +104,38 @@ bool FixedShapeTensorType::ExtensionEquals(const ExtensionType& other) const {
          permutation_equivalent;
 }
 
+std::string FixedShapeTensorType::ToString() const {
+  std::stringstream ss;
+  ss << "extension<" << this->extension_name()
+     << "[value_type=" << value_type_->ToString() << ", shape=[";
+  std::string separator;
+  for (auto v : shape_) {
+    ss << separator << v;
+    separator = ",";
+  }
+  ss << "]";
+  if (!permutation_.empty()) {
+    ss << ", permutation=[";
+    std::string p_separator;
+    for (auto v : permutation_) {
+      ss << p_separator << v;
+      p_separator = ",";
+    }
+    ss << "]";
+  }
+  if (!dim_names_.empty()) {
+    ss << ", dim_names=[";
+    std::string d_separator;
+    for (std::string v : dim_names_) {
+      ss << d_separator << v;
+      d_separator = ",";
+    }
+    ss << "]";
+  }
+  ss << "]>";
+  return ss.str();
+}
+

Review Comment:
   Thank you all for constructive feedback!
   I was a bit distracted but will get back to it now - will try what Ben suggested.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org