Skip to content
Snippets Groups Projects
Commit 4f3855e6 authored by Bert Palm's avatar Bert Palm 🎇
Browse files

started test aloc

parent 30da8d83
No related branches found
No related tags found
No related merge requests found
...@@ -41,5 +41,5 @@ def test__setitem_single(dios_aligned, idxer, exp): ...@@ -41,5 +41,5 @@ def test__setitem_single(dios_aligned, idxer, exp):
@pytest.mark.parametrize('idxer', BASIC_INDEXER_FAIL) @pytest.mark.parametrize('idxer', BASIC_INDEXER_FAIL)
def test__setitem__fail(dios_aligned, idxer): def test__setitem__fail(dios_aligned, idxer):
with pytest.raises((ValueError, KeyError, IndexError)): with pytest.raises((ValueError, KeyError, IndexError)):
dios_aligned[idxer] dios_aligned[idxer] = 99
# from .test_setup import * from .test_setup import *
# from pandas.core.dtypes.common import is_scalar from pandas.core.dtypes.common import is_scalar
#
# unal1 = pd.Series(range(10), index=range(10))
# unal2 = pd.Series(range(5, 10), index=range(5, 10)) @pytest.mark.parametrize(('idxer', 'exp'), [('a', s1), ('c', s3), ('x', pd.Series())])
# unal3 = pd.Series(range(1, 30, 2), index=range(1, 30, 2)) def test__getitem_aloc_singleCol(dios_aligned, idxer, exp):
# unal4 = pd.Series(np.linspace(7, 13, 9), index=range(3, 12)) di = dios_aligned.aloc[:, idxer]
# unal1.name, unal2.name, unal3.name, unal4.name = 'a', 'b', 'c', 'd' assert isinstance(di, pd.Series)
# d1 = DictOfSeries(data=dict(a=unal1.copy(), b=unal2.copy(), c=unal3.copy(), d=unal4.copy())) assert (di == exp).all()
#
#
# @pytest.mark.parametrize(('idxer', 'exp'), [('a', unal1), ('c', unal3)]) @pytest.mark.parametrize(('idxer', 'exp'), [((1, 'a'), s1), ((3, 'c'), s3)])
# def test__getitem_single(idxer, exp): def test__getitem_aloc_singleRow_singleCol(dios_aligned, idxer, exp):
# a = d1[idxer] di = dios_aligned.aloc[idxer]
# b = d1.loc[:, idxer] assert is_scalar(di)
# assert isinstance(a, pd.Series) assert di == exp.aloc[idxer[0]]
# assert isinstance(b, pd.Series)
# assert (a == exp).all()
# assert (b == exp).all() @pytest.mark.parametrize('idxer', ['x', '2', 1, None, ])
# def test__getitem_aloc_singleCol_fail(dios_aligned, idxer):
# with pytest.raises((KeyError, TypeError)):
# @pytest.mark.parametrize(('idxer', 'exp'), [((1, 'a'), unal1), ((3, 'c'), unal3)]) di = dios_aligned.aloc[:, idxer]
# def test__getitem_scalar_loc(idxer, exp):
# a = d1.loc[idxer]
# assert is_scalar(a) @pytest.mark.parametrize('idxerL', R_LOC_INDEXER)
# assert a == exp.loc[idxer[0]] @pytest.mark.parametrize('idxerR', C_LOC_INDEXER)
# def test__getitem__aloc(dios_aligned, idxerL, idxerR):
# di = dios_aligned.copy().aloc[idxerL, idxerR]
# @pytest.mark.parametrize(('idxer', 'exp'), [(0, unal1), (1, unal2), (2, unal3), (3, unal4), exp = dios_aligned.copy().loc[idxerL, idxerR]
# (-1, unal4), (-2, unal3), (-3, unal2), (-4, unal1)]) assert isinstance(di, DictOfSeries)
# def test__getitem_single_iloc(idxer, exp): assert (di == exp).all(None)
# a = d1.iloc[:, idxer] # #############################
# assert isinstance(a, pd.Series) # __SETITEM__
# assert (a == exp).all()
# @pytest.mark.parametrize(('idxer', 'exp'), [(slice(None), [s1 == s1, s2 == s2, s3 == s3, s4 == s4]),
# (C_BLIST, [s1 == s1, s2 != s2, s3 != s3, s4 == s4]),
# @pytest.mark.parametrize(('idxer', 'exp'), [((1, 0), unal1), ((3, -2), unal3), ((-1, -1), unal4)]) ])
# def test__getitem_scalar_iloc(idxer, exp): def test__setitem_aloc_singleCol(dios_aligned, idxer, exp):
# a = d1.iloc[idxer] di = dios_aligned.copy()
# assert is_scalar(a) di.aloc[:, idxer] = 99
# assert a == exp.iloc[idxer[0]] for i, c in enumerate(di):
# assert ((di[c] == 99) == exp[i]).all()
#
# @pytest.mark.parametrize('idxer', ['x', '2', 1000, None, ])
# def test__getitem_single_fail(idxer): VALS = [99,
# with pytest.raises((KeyError, ValueError)): pd.Series(range(4, 10), index=range(4, 10)),
# a = d1[idxer] ]
# print(idxer, a)
#
# @pytest.mark.parametrize('idxerL', R_LOC_INDEXER)
# @pytest.mark.parametrize('idxer', ['x', '2', 1, None, ]) @pytest.mark.parametrize('idxerR', C_LOC_INDEXER)
# def test__getitem_single_loc_fail(idxer): @pytest.mark.parametrize('val', VALS)
# with pytest.raises((KeyError, TypeError)): def test__setitem__aloc(dios_aligned, idxerL, idxerR, val):
# a = d1.loc[:, idxer] di = dios_aligned.copy()
# di.aloc[idxerL, idxerR] = val
# exp = dios_aligned.copy()
# @pytest.mark.parametrize('idxer', [-5, 99, 'a', '2', None, ]) di.loc[idxerL, idxerR] = val
# def test__getitem_single_iloc_fail(idxer): assert isinstance(di, DictOfSeries)
# with pytest.raises((KeyError, IndexError, TypeError)): assert (di == exp).all(None)
# a = d1.iloc[:, idxer]
#
#
# @pytest.mark.parametrize('idxer', INDEXERS_NOBOOL)
# def test__getitem_(idxer):
# d = d1[idxer]
# assert isinstance(d, DictOfSeries)
#
#
# @pytest.mark.parametrize('idxer', FAIL_INDEXERS)
# def test__getitem_fail(idxer):
# with pytest.raises((ValueError, KeyError)):
# d1[idxer]
#
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment