Skip to content
This repository was archived by the owner on Apr 10, 2024. It is now read-only.

Commit 4f7ebcb

Browse files
committed
TST: test coverage
1 parent 76da01b commit 4f7ebcb

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

pandas/sparse/frame.py

+7-14
Original file line numberDiff line numberDiff line change
@@ -408,26 +408,16 @@ def xs(self, key, axis=0, copy=False):
408408
# Arithmetic-related methods
409409

410410
def _combine_frame(self, other, func, fill_value=None, level=None):
411-
new_index = self.index.union(other.index)
412-
new_columns = self.columns.union(other.columns)
411+
this, other = self.align(other, join='outer', level=level,
412+
copy=False)
413+
new_index, new_columns = this.index, this.columns
413414

414415
if fill_value is not None or level is not None:
415416
raise NotImplementedError
416417

417-
this = self
418-
if self.index is not new_index:
419-
this = self.reindex(new_index)
420-
other = other.reindex(new_index)
421-
422418
if not self and not other:
423419
return SparseDataFrame(index=new_index)
424420

425-
if not other:
426-
return self * nan
427-
428-
if not self:
429-
return other * nan
430-
431421
new_data = {}
432422
for col in new_columns:
433423
if col in this and col in other:
@@ -535,7 +525,10 @@ def _reindex_with_indexers(self, index, row_indexer, columns, col_indexer,
535525
for col in columns:
536526
if col not in self:
537527
continue
538-
new_arrays[col] = com.take_1d(self[col].values, row_indexer)
528+
if row_indexer is not None:
529+
new_arrays[col] = com.take_1d(self[col].values, row_indexer)
530+
else:
531+
new_arrays[col] = self[col]
539532

540533
return self._constructor(new_arrays, index=index, columns=columns)
541534

pandas/sparse/tests/test_sparse.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -872,10 +872,10 @@ def test_op_corners(self):
872872
self.assert_(not empty)
873873

874874
foo = self.frame + self.empty
875-
assert_sp_frame_equal(foo, self.frame * np.nan)
875+
assert_frame_equal(foo, self.frame * np.nan)
876876

877877
foo = self.empty + self.frame
878-
assert_sp_frame_equal(foo, self.frame * np.nan)
878+
assert_frame_equal(foo, self.frame * np.nan)
879879

880880
def test_scalar_ops(self):
881881
pass

0 commit comments

Comments
 (0)