]>
git.proxmox.com Git - ceph.git/blob - ceph/src/arrow/c_glib/test/test-tensor.rb
1 # Licensed to the Apache Software Foundation (ASF) under one
2 # or more contributor license agreements. See the NOTICE file
3 # distributed with this work for additional information
4 # regarding copyright ownership. The ASF licenses this file
5 # to you under the Apache License, Version 2.0 (the
6 # "License"); you may not use this file except in compliance
7 # with the License. You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing,
12 # software distributed under the License is distributed on an
13 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 # KIND, either express or implied. See the License for the
15 # specific language governing permissions and limitations
18 class TestTensor
< Test
::Unit::TestCase
19 include Helper
::Omittable
32 data = Arrow
::Buffer.new(@raw_data.pack("c*"))
35 names
= ["a", "b", "c"]
36 @tensor = Arrow
::Tensor.new(Arrow
::Int8DataType.new
,
44 data = Arrow
::Buffer.new(@raw_data.pack("c*"))
46 names
= ["a", "b", "c"]
47 other_tensor
= Arrow
::Tensor.new(Arrow
::Int8DataType.new
,
56 def test_value_data_type
57 assert_equal(Arrow
::Int8DataType, @tensor.value_data_type
.class)
61 assert_equal(Arrow
::Type::INT8, @tensor.value_type
)
65 assert_equal(@raw_data, @tensor.buffer
.data.to_s
.unpack("c*"))
69 require_gi_bindings(3, 3, 1)
70 assert_equal(@shape, @tensor.shape
)
74 require_gi_bindings(3, 3, 1)
75 assert_equal([4, 2, 1], @tensor.strides
)
79 assert_equal(@shape.size
, @tensor.n_dimensions
)
82 def test_dimension_name
83 dimension_names
= @tensor.n_dimensions
.times
.collect
do |i
|
84 @tensor.get_dimension_name(i
)
86 assert_equal(["a", "b", "c"],
91 assert_equal(@raw_data.size
, @tensor.size
)
112 def test_column_major
?
114 not @tensor.column_major
?
119 buffer
= Arrow
::ResizableBuffer.new(0)
120 output
= Arrow
::BufferOutputStream.new(buffer
)
121 output
.write_tensor(@tensor)
122 input
= Arrow
::BufferInputStream.new(buffer
)
123 assert_equal(@tensor, input
.read_tensor
)