| 16 | # under the License. |
| 17 | |
| 18 | class 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 |
nothing calls this directly
no test coverage detected