You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by we...@apache.org on 2019/03/05 02:11:41 UTC
[arrow] branch master updated: ARROW-4388 [Go] add DimNames()
method to tensor Interface
This is an automated email from the ASF dual-hosted git repository.
wesm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new 07143f1 ARROW-4388 [Go] add DimNames() method to tensor Interface
07143f1 is described below
commit 07143f1f8fa720d2c260c56564927f7b1af4d713
Author: Anson Qian <ab...@uber.com>
AuthorDate: Mon Mar 4 20:11:30 2019 -0600
ARROW-4388 [Go] add DimNames() method to tensor Interface
https://issues.apache.org/jira/browse/ARROW-4388
Author: Anson Qian <ab...@uber.com>
Closes #3600 from anson627/arrow-4388 and squashes the following commits:
03722323f <Anson Qian> Address code review
55d14d309 <Anson Qian> ARROW-4388 add DimNames() method to tensor Interface
---
go/arrow/tensor/tensor.go | 4 ++++
go/arrow/tensor/tensor_test.go | 4 ++++
2 files changed, 8 insertions(+)
diff --git a/go/arrow/tensor/tensor.go b/go/arrow/tensor/tensor.go
index 53d5a45..ea9f15e 100644
--- a/go/arrow/tensor/tensor.go
+++ b/go/arrow/tensor/tensor.go
@@ -52,6 +52,9 @@ type Interface interface {
// DimName returns the name of the i-th dimension.
DimName(i int) string
+ // DimNames returns the names for all dimensions
+ DimNames() []string
+
DataType() arrow.DataType
Data() *array.Data
@@ -104,6 +107,7 @@ func (tb *tensorBase) NumDims() int { return len(tb.shape) }
func (tb *tensorBase) DimName(i int) string { return tb.names[i] }
func (tb *tensorBase) DataType() arrow.DataType { return tb.dtype }
func (tb *tensorBase) Data() *array.Data { return tb.data }
+func (tb *tensorBase) DimNames() []string { return tb.names }
// IsMutable returns whether the underlying data buffer is mutable.
func (tb *tensorBase) IsMutable() bool { return false } // FIXME(sbinet): implement it at the array.Data level
diff --git a/go/arrow/tensor/tensor_test.go b/go/arrow/tensor/tensor_test.go
index cb2631c..3746f30 100644
--- a/go/arrow/tensor/tensor_test.go
+++ b/go/arrow/tensor/tensor_test.go
@@ -67,6 +67,10 @@ func TestTensor(t *testing.T) {
t.Fatalf("invalid dims: got=%d, want=%d", got, want)
}
+ if got, want := f64.DimNames(), names; !reflect.DeepEqual(got, want) {
+ t.Fatalf("invalid dim-names: got=%v, want=%v", got, want)
+ }
+
for i, name := range names {
if got, want := f64.DimName(i), name; got != want {
t.Fatalf("invalid dim-name[%d]: got=%q, want=%q", i, got, want)