Skip to content

Commit

Permalink
Fix all but 3 Python unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wesm committed May 17, 2019
1 parent ab7fc17 commit f1178b2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 24 deletions.
2 changes: 1 addition & 1 deletion python/pyarrow/tests/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ def test_cast_from_null():
_check_cast_case((in_data, in_type, in_data, out_type))

out_types = [
pa.dictionary(pa.int32(), pa.array(['a', 'b', 'c'])),
pa.dictionary(pa.int32(), pa.string()),
pa.union([pa.field('a', pa.binary(10)),
pa.field('b', pa.string())], mode=pa.lib.UnionMode_DENSE),
pa.union([pa.field('a', pa.binary(10)),
Expand Down
3 changes: 1 addition & 2 deletions python/pyarrow/tests/test_compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ def test_take_indices_types():
arr.take(indices)


@pytest.mark.parametrize('ordered', [
False, pytest.param(True, marks=pytest.mark.xfail(strict=True))])
@pytest.mark.parametrize('ordered', [False, True])
def test_take_dictionary(ordered):
arr = pa.DictionaryArray.from_arrays([0, 1, 2, 0, 1, 2], ['a', 'b', 'c'],
ordered=ordered)
Expand Down
9 changes: 1 addition & 8 deletions python/pyarrow/tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,22 +415,15 @@ def test_schema_negative_indexing():


def test_schema_repr_with_dictionaries():
dct = pa.array(['foo', 'bar', 'baz'], type=pa.string())
fields = [
pa.field('one', pa.dictionary(pa.int16(), dct)),
pa.field('one', pa.dictionary(pa.int16(), pa.string())),
pa.field('two', pa.int32())
]
sch = pa.schema(fields)

expected = (
"""\
one: dictionary<values=string, indices=int16, ordered=0>
dictionary:
[
"foo",
"bar",
"baz"
]
two: int32""")

assert repr(sch) == expected
Expand Down
21 changes: 8 additions & 13 deletions python/pyarrow/tests/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def get_many_types():
pa.field('b', pa.string())], mode=pa.lib.UnionMode_SPARSE),
pa.union([pa.field('a', pa.binary(10), nullable=False),
pa.field('b', pa.string())], mode=pa.lib.UnionMode_SPARSE),
pa.dictionary(pa.int32(), pa.array(['a', 'b', 'c']))
pa.dictionary(pa.int32(), pa.string())
)


Expand Down Expand Up @@ -113,9 +113,7 @@ def test_is_list():


def test_is_dictionary():
assert types.is_dictionary(
pa.dictionary(pa.int32(),
pa.array(['a', 'b', 'c'])))
assert types.is_dictionary(pa.dictionary(pa.int32(), pa.string()))
assert not types.is_dictionary(pa.int32())


Expand Down Expand Up @@ -308,23 +306,20 @@ def check_fields(ty, fields):


def test_dictionary_type():
ty0 = pa.dictionary(pa.int32(), pa.array(['a', 'b', 'c']))
ty0 = pa.dictionary(pa.int32(), pa.string())
assert ty0.index_type == pa.int32()
assert isinstance(ty0.dictionary, pa.Array)
assert ty0.dictionary.to_pylist() == ['a', 'b', 'c']
assert ty0.value_type == pa.string()
assert ty0.ordered is False

ty1 = pa.dictionary(pa.int8(), pa.array([1.0, 2.0]), ordered=True)
ty1 = pa.dictionary(pa.int8(), pa.float64(), ordered=True)
assert ty1.index_type == pa.int8()
assert isinstance(ty0.dictionary, pa.Array)
assert ty1.dictionary.to_pylist() == [1.0, 2.0]
assert ty1.value_type == pa.float64()
assert ty1.ordered is True

# construct from non-arrow objects
ty2 = pa.dictionary('int8', ['a', 'b', 'c', 'd'])
ty2 = pa.dictionary('int8', 'string')
assert ty2.index_type == pa.int8()
assert isinstance(ty2.dictionary, pa.Array)
assert ty2.dictionary.to_pylist() == ['a', 'b', 'c', 'd']
assert ty2.value_type == pa.string()
assert ty2.ordered is False


Expand Down

0 comments on commit f1178b2

Please sign in to comment.