MCPcopy Create free account
hub / github.com/apache/arrow / TensorTest

Class TensorTest

ruby/red-arrow/test/test-tensor.rb:18–297  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16# under the License.
17
18class TensorTest < Test::Unit::TestCase
19 sub_test_case("class methods") do
20 sub_test_case(".new") do
21 def setup
22 @raw_tensor = [
23 [
24 [1, 2, 3, 4],
25 [5, 6, 7, 8],
26 ],
27 [
28 [9, 10, 11, 12],
29 [13, 14, 15, 16],
30 ],
31 [
32 [17, 18, 19, 20],
33 [21, 22, 23, 24],
34 ],
35 ]
36 @shape = [3, 2, 4]
37 @strides = [8, 4, 1]
38 end
39
40 test("Array") do
41 tensor = Arrow::Tensor.new(@raw_tensor)
42 assert_equal({
43 value_data_type: Arrow::UInt8DataType.new,
44 buffer: @raw_tensor.flatten.pack("C*"),
45 shape: @shape,
46 strides: @strides,
47 dimension_names: ["", "", ""],
48 },
49 {
50 value_data_type: tensor.value_data_type,
51 buffer: tensor.buffer.data.to_s,
52 shape: tensor.shape,
53 strides: tensor.strides,
54 dimension_names: tensor.dimension_names,
55 })
56 end
57
58 test("Array, data_type: Symbol") do
59 tensor = Arrow::Tensor.new(@raw_tensor, data_type: :int32)
60 assert_equal({
61 value_data_type: Arrow::Int32DataType.new,
62 buffer: @raw_tensor.flatten.pack("l*"),
63 shape: @shape,
64 strides: @strides.collect {|x| x * 4},
65 dimension_names: ["", "", ""],
66 },
67 {
68 value_data_type: tensor.value_data_type,
69 buffer: tensor.buffer.data.to_s,
70 shape: tensor.shape,
71 strides: tensor.strides,
72 dimension_names: tensor.dimension_names,
73 })
74 end
75

Callers

nothing calls this directly

Calls 14

testFunction · 0.85
dimension_namesMethod · 0.80
freezeMethod · 0.80
newMethod · 0.45
packMethod · 0.45
value_data_typeMethod · 0.45
to_sMethod · 0.45
dataMethod · 0.45
bufferMethod · 0.45
shapeMethod · 0.45
stridesMethod · 0.45
inspectMethod · 0.45

Tested by

no test coverage detected