Skip to content

Commit b989135

Browse files
committed
TST: misc coverage and cleanup
1 parent 96c1468 commit b989135

File tree

5 files changed

+24
-50
lines changed

5 files changed

+24
-50
lines changed

pandas/core/internals.py

-29
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,6 @@ def shape(self):
559559
return tuple(len(ax) for ax in self.axes)
560560

561561
def _verify_integrity(self):
562-
# _union_block_items(self.blocks)
563562
mgr_shape = self.shape
564563
for block in self.blocks:
565564
assert(block.ref_items is self.items)
@@ -1404,34 +1403,6 @@ def _merge_blocks(blocks, items):
14041403
new_block = make_block(new_values, new_items, items)
14051404
return new_block.reindex_items_from(items)
14061405

1407-
def _union_block_items(blocks):
1408-
tot_len = 0
1409-
all_items = []
1410-
slow = False
1411-
for b in blocks:
1412-
tot_len += len(b.items)
1413-
if type(b.items) != Index:
1414-
slow = True
1415-
all_items.append(b.items)
1416-
1417-
if slow:
1418-
the_union = _union_items_slow(all_items)
1419-
else:
1420-
the_union = Index(lib.fast_unique_multiple(all_items))
1421-
1422-
if tot_len > len(the_union):
1423-
raise Exception('item names overlap')
1424-
return the_union
1425-
1426-
def _union_items_slow(all_items):
1427-
seen = None
1428-
for items in all_items:
1429-
if seen is None:
1430-
seen = items
1431-
else:
1432-
seen = seen.union(items)
1433-
return seen
1434-
14351406
def _vstack(to_stack):
14361407
if all(x.dtype == _NS_DTYPE for x in to_stack):
14371408
# work around NumPy 1.6 bug

pandas/core/strings.py

+2-10
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,8 @@ def str_cat(arr, others=None, sep=None, na_rep=None):
5151

5252
notmask = -na_mask
5353

54-
if sep is None:
55-
for x in arrays:
56-
x = x[notmask]
57-
if cats is None:
58-
cats = x
59-
else:
60-
cats = cats + x[notmask]
61-
else:
62-
tuples = izip(*[x[notmask] for x in arrays])
63-
cats = [sep.join(tup) for tup in tuples]
54+
tuples = izip(*[x[notmask] for x in arrays])
55+
cats = [sep.join(tup) for tup in tuples]
6456

6557
result[notmask] = cats
6658
else:

pandas/tests/test_graphics.py

+21
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,8 @@ def test_style_by_column(self):
466466
@slow
467467
def test_line_colors(self):
468468
import matplotlib.pyplot as plt
469+
import sys
470+
from StringIO import StringIO
469471

470472
custom_colors = 'rgcby'
471473

@@ -480,6 +482,16 @@ def test_line_colors(self):
480482
rs = l.get_color()
481483
self.assert_(xp == rs)
482484

485+
tmp = sys.stderr
486+
sys.stderr = StringIO()
487+
try:
488+
plt.close('all')
489+
ax2 = df.plot(colors=custom_colors)
490+
lines2 = ax2.get_lines()
491+
for l1, l2 in zip(lines, lines2):
492+
self.assert_(l1.get_color(), l2.get_color())
493+
finally:
494+
sys.stderr = tmp
483495

484496
class TestDataFrameGroupByPlots(unittest.TestCase):
485497

@@ -513,6 +525,8 @@ def test_boxplot(self):
513525
_check_plot_works(grouped.boxplot)
514526
_check_plot_works(grouped.boxplot, subplots=False)
515527

528+
529+
516530
@slow
517531
def test_series_plot_color_kwargs(self):
518532
# #1890
@@ -533,6 +547,13 @@ def test_time_series_plot_color_kwargs(self):
533547
line = ax.get_lines()[0]
534548
self.assert_(line.get_color() == 'green')
535549

550+
@slow
551+
def test_grouped_hist(self):
552+
df = DataFrame(np.random.randn(50, 2), columns=['A', 'B'])
553+
df['C'] = np.random.randint(0, 3, 50)
554+
axes = plotting.grouped_hist(df.A, by=df.C)
555+
self.assert_(len(axes.ravel()) == 4)
556+
536557
PNG_PATH = 'tmp.png'
537558

538559
def _check_plot_works(f, *args, **kwargs):

pandas/tests/test_internals.py

-10
Original file line numberDiff line numberDiff line change
@@ -236,16 +236,6 @@ def test_block_id_vector_item_dtypes(self):
236236
'bool', 'int64', 'complex128']
237237
self.assert_(np.array_equal(result, expected))
238238

239-
def test_union_block_items(self):
240-
blocks = [get_float_ex(['a', 'b', 'c']),
241-
get_float_ex(['c', 'd', 'e'])]
242-
self.assertRaises(Exception, internals._union_block_items, blocks)
243-
244-
blocks = [get_float_ex(['a', 'b', 'c']),
245-
get_float_ex(['f', 'e', 'd'])]
246-
self.assert_(np.array_equal(internals._union_block_items(blocks),
247-
['a', 'b', 'c', 'd', 'e', 'f']))
248-
249239
def test_duplicate_item_failure(self):
250240
items = Index(['a', 'a'])
251241
blocks = [get_bool_ex(['a']), get_float_ex(['a'])]

pandas/tools/plotting.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ def plot_group(group, ax):
487487
figsize=figsize, layout=layout, rot=rot)
488488
fig.subplots_adjust(bottom=0.15, top=0.9, left=0.1, right=0.9,
489489
hspace=0.3, wspace=0.2)
490-
return fig
490+
return axes
491491

492492
class MPLPlot(object):
493493
"""

0 commit comments

Comments
 (0)