conftest.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # -*- coding: utf-8 -*-
  2. import numpy as np
  3. import pytest
  4. from pandas import Index, MultiIndex
  5. @pytest.fixture
  6. def idx():
  7. # a MultiIndex used to test the general functionality of the
  8. # general functionality of this object
  9. major_axis = Index(['foo', 'bar', 'baz', 'qux'])
  10. minor_axis = Index(['one', 'two'])
  11. major_codes = np.array([0, 0, 1, 2, 3, 3])
  12. minor_codes = np.array([0, 1, 0, 1, 0, 1])
  13. index_names = ['first', 'second']
  14. mi = MultiIndex(levels=[major_axis, minor_axis],
  15. codes=[major_codes, minor_codes],
  16. names=index_names, verify_integrity=False)
  17. return mi
  18. @pytest.fixture
  19. def idx_dup():
  20. # compare tests/indexes/multi/conftest.py
  21. major_axis = Index(['foo', 'bar', 'baz', 'qux'])
  22. minor_axis = Index(['one', 'two'])
  23. major_codes = np.array([0, 0, 1, 0, 1, 1])
  24. minor_codes = np.array([0, 1, 0, 1, 0, 1])
  25. index_names = ['first', 'second']
  26. mi = MultiIndex(levels=[major_axis, minor_axis],
  27. codes=[major_codes, minor_codes],
  28. names=index_names, verify_integrity=False)
  29. return mi
  30. @pytest.fixture
  31. def index_names():
  32. # names that match those in the idx fixture for testing equality of
  33. # names assigned to the idx
  34. return ['first', 'second']
  35. @pytest.fixture
  36. def holder():
  37. # the MultiIndex constructor used to base compatibility with pickle
  38. return MultiIndex
  39. @pytest.fixture
  40. def compat_props():
  41. # a MultiIndex must have these properties associated with it
  42. return ['shape', 'ndim', 'size']