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

Class TableTest

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

Source from the content-addressed store, hash-verified

16# under the License.
17
18class TableTest < Test::Unit::TestCase
19 include Helper::Fixture
20
21 def setup
22 @count_field = Arrow::Field.new("count", :uint8)
23 @visible_field = Arrow::Field.new("visible", :boolean)
24 schema = Arrow::Schema.new([@count_field, @visible_field])
25 count_arrays = [
26 Arrow::UInt8Array.new([1, 2]),
27 Arrow::UInt8Array.new([4, 8, 16]),
28 Arrow::UInt8Array.new([32, 64]),
29 Arrow::UInt8Array.new([128]),
30 ]
31 visible_arrays = [
32 Arrow::BooleanArray.new([true, false, nil]),
33 Arrow::BooleanArray.new([true]),
34 Arrow::BooleanArray.new([true, false]),
35 Arrow::BooleanArray.new([nil]),
36 Arrow::BooleanArray.new([nil]),
37 ]
38 @count_array = Arrow::ChunkedArray.new(count_arrays)
39 @visible_array = Arrow::ChunkedArray.new(visible_arrays)
40 @table = Arrow::Table.new(schema, [@count_array, @visible_array])
41 end
42
43 sub_test_case(".new") do
44 test("{Symbol: Arrow::Array}") do
45 schema = Arrow::Schema.new(numbers: :int64)
46 assert_equal(Arrow::Table.new(schema,
47 [Arrow::Int64Array.new([1, 2, 3])]),
48 Arrow::Table.new(numbers: Arrow::Int64Array.new([1, 2, 3])))
49 end
50
51 test("{Symbol: Arrow::ChunkedArray}") do
52 chunked_array = Arrow::ChunkedArray.new([Arrow::Int64Array.new([1, 2, 3])])
53 schema = Arrow::Schema.new(numbers: :int64)
54 assert_equal(Arrow::Table.new(schema,
55 [Arrow::Int64Array.new([1, 2, 3])]),
56 Arrow::Table.new(numbers: chunked_array))
57 end
58
59 test("{Symbol: Arrow::Tensor}") do
60 schema = Arrow::Schema.new(numbers: :uint8)
61 assert_equal(Arrow::Table.new(schema,
62 [Arrow::UInt8Array.new([1, 2, 3])]),
63 Arrow::Table.new(numbers: Arrow::Tensor.new([1, 2, 3])))
64 end
65
66 test("{Symbol: #to_ary}") do
67 array_like = Object.new
68 def array_like.to_ary
69 [1, 2, 3]
70 end
71 schema = Arrow::Schema.new(numbers: :uint8)
72 assert_equal(Arrow::Table.new(schema, [Arrow::UInt8Array.new([1, 2, 3])]),
73 Arrow::Table.new(numbers: array_like))
74 end
75 end

Callers

nothing calls this directly

Calls 15

testFunction · 0.85
columnsMethod · 0.80
filterMethod · 0.80
dataClass · 0.50
newMethod · 0.45
to_sMethod · 0.45
sliceMethod · 0.45
to_hMethod · 0.45
n_rowsMethod · 0.45
mergeMethod · 0.45
lengthMethod · 0.45
remove_columnMethod · 0.45

Tested by

no test coverage detected