test_bool.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import numpy as np
  2. import pytest
  3. import pandas as pd
  4. from pandas.tests.extension import base
  5. import pandas.util.testing as tm
  6. pytest.importorskip('pyarrow', minversion="0.10.0")
  7. from .bool import ArrowBoolArray, ArrowBoolDtype # isort:skip
  8. @pytest.fixture
  9. def dtype():
  10. return ArrowBoolDtype()
  11. @pytest.fixture
  12. def data():
  13. return ArrowBoolArray.from_scalars(np.random.randint(0, 2, size=100,
  14. dtype=bool))
  15. @pytest.fixture
  16. def data_missing():
  17. return ArrowBoolArray.from_scalars([None, True])
  18. class BaseArrowTests(object):
  19. pass
  20. class TestDtype(BaseArrowTests, base.BaseDtypeTests):
  21. def test_array_type_with_arg(self, data, dtype):
  22. pytest.skip("GH-22666")
  23. class TestInterface(BaseArrowTests, base.BaseInterfaceTests):
  24. def test_repr(self, data):
  25. raise pytest.skip("TODO")
  26. class TestConstructors(BaseArrowTests, base.BaseConstructorsTests):
  27. def test_from_dtype(self, data):
  28. pytest.skip("GH-22666")
  29. # seems like some bug in isna on empty BoolArray returning floats.
  30. @pytest.mark.xfail(reason='bad is-na for empty data')
  31. def test_from_sequence_from_cls(self, data):
  32. super(TestConstructors, self).test_from_sequence_from_cls(data)
  33. class TestReduce(base.BaseNoReduceTests):
  34. def test_reduce_series_boolean(self):
  35. pass
  36. class TestReduceBoolean(base.BaseBooleanReduceTests):
  37. pass
  38. def test_is_bool_dtype(data):
  39. assert pd.api.types.is_bool_dtype(data)
  40. assert pd.core.common.is_bool_indexer(data)
  41. s = pd.Series(range(len(data)))
  42. result = s[data]
  43. expected = s[np.asarray(data)]
  44. tm.assert_series_equal(result, expected)