Skip to content

Commit

Permalink
fixup: further fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kernc committed Oct 10, 2017
1 parent c817554 commit 65b2392
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
5 changes: 0 additions & 5 deletions pandas/core/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1933,11 +1933,6 @@ def _has_valid_setitem_indexer(self, indexer):

def _convert_key(self, key, is_setter=False):
""" require integer args (and convert to label arguments) """

# allow arbitrary setting
if is_setter:
return list(key)

for a, i in zip(self.obj.axes, key):
if not is_integer(i):
raise ValueError("iAt based indexing can only have integer "
Expand Down
6 changes: 2 additions & 4 deletions pandas/core/internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -2765,8 +2765,7 @@ def _can_hold_element(self, element):
return np.can_cast(np.asarray(element).dtype, self.sp_values.dtype)

def _try_coerce_result(self, result):
if (
# isinstance(result, np.ndarray) and
if (isinstance(result, np.ndarray) and
np.ndim(result) > 0
and not is_sparse(result)):
result = SparseArray(result, kind=self.kind,
Expand Down Expand Up @@ -3770,8 +3769,7 @@ def fast_xs(self, loc):
# Such assignment may incorrectly coerce NaT to None
# result[blk.mgr_locs] = blk._slice((slice(None), loc))
for i, rl in enumerate(blk.mgr_locs):
# result[rl] = blk._try_coerce_result(blk.iget((i, loc)))
result[rl] = blk.iget((i, loc))
result[rl] = blk._try_coerce_result(blk.iget((i, loc)))

return result

Expand Down
13 changes: 8 additions & 5 deletions pandas/tests/sparse/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1424,19 +1424,22 @@ def spindex_kind(request):
return request.param


@pytest.mark.parametrize('indexer', ['at', 'iat'])
@pytest.mark.parametrize('key', [0])
@pytest.mark.parametrize('indexer', ['iat'])
@pytest.mark.parametrize('key', [(0, 0)])
def test_frame_assignment_at(spindex_kind, indexer, key):
_test_assignment(spindex_kind, indexer, key)


@pytest.mark.parametrize('indexer', ['loc', 'iloc'])
@pytest.mark.parametrize('key', [0, [0, 1], [True, False]])
@pytest.mark.parametrize('indexer', ['at', 'loc', 'iloc'])
@pytest.mark.parametrize('key', [0,
[0, 1],
[True, False]])
def test_frame_assignment_loc(spindex_kind, indexer, key):
_test_assignment(spindex_kind, indexer, key)


@pytest.mark.parametrize('key', [None, [True, False]])
@pytest.mark.parametrize('key', [None,
[True, False]])
def test_frame_assignment_setitem(spindex_kind, key):
_test_assignment(spindex_kind, None, key)

Expand Down

0 comments on commit 65b2392

Please sign in to comment.