def test_constructor(self): # missing data arg with pytest.raises(TypeError): # noinspection PyArgumentList UniqueIndex() # data has wrong dimensions data = [['A', 'C'], ['B', 'F']] with pytest.raises(TypeError): UniqueIndex(data) # labels are not unique data = ['A', 'B', 'D', 'B'] with pytest.raises(ValueError): UniqueIndex(data) # valid data data = ['A', 'C', 'B', 'F'] lbl = UniqueIndex(data) aeq(data, lbl) assert 1 == lbl.ndim assert 4 == len(lbl) # valid data (typed) data = np.array(['A', 'C', 'B', 'F'], dtype='S1') lbl = UniqueIndex(data, dtype='S1') aeq(data, lbl)
def test_slice(self): data = ['A', 'C', 'B', 'F'] lbl = UniqueIndex(data) # row slice s = lbl[1:] assert isinstance(s, UniqueIndex) # index s = lbl[0] assert isinstance(s, str) assert not isinstance(s, UniqueIndex)
def setup_instance(self, data): return UniqueIndex(data)