Skip to content

CLN: Python 3.4 deprecation of assert_ #7162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 18, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pandas/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def test_value_counts_unique_nunique(self):

if isinstance(o, DatetimeIndex):
# DatetimeIndex.unique returns DatetimeIndex
self.assert_(o.unique().equals(klass(values)))
self.assertTrue(o.unique().equals(klass(values)))
else:
self.assert_numpy_array_equal(o.unique(), values)

Expand Down Expand Up @@ -262,9 +262,9 @@ def test_value_counts_unique_nunique(self):
self.assert_numpy_array_equal(result[1:], values[2:])

if isinstance(o, DatetimeIndex):
self.assert_(result[0] is pd.NaT)
self.assertTrue(result[0] is pd.NaT)
else:
self.assert_(pd.isnull(result[0]))
self.assertTrue(pd.isnull(result[0]))

if isinstance(o, DatetimeIndex):
self.assertEqual(o.nunique(), 9)
Expand Down Expand Up @@ -351,7 +351,7 @@ def test_value_counts_inferred(self):
dtype='datetime64[ns]')
if isinstance(s, DatetimeIndex):
expected = DatetimeIndex(expected)
self.assert_(s.unique().equals(expected))
self.assertTrue(s.unique().equals(expected))
else:
self.assert_numpy_array_equal(s.unique(), expected)

Expand Down
38 changes: 19 additions & 19 deletions pandas/tests/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -5089,7 +5089,7 @@ def _check_unaligned_frame(meth, op, df, other):

# DataFrame
self.assert_(df.eq(df).values.all())
self.assert_(not df.ne(df).values.any())
self.assertFalse(df.ne(df).values.any())
for op in ['eq', 'ne', 'gt', 'lt', 'ge', 'le']:
f = getattr(df, op)
o = getattr(operator, op)
Expand Down Expand Up @@ -5149,17 +5149,17 @@ def _test_seq(df, idx_ser, col_ser):
# NA
df.ix[0, 0] = np.nan
rs = df.eq(df)
self.assert_(not rs.ix[0, 0])
self.assertFalse(rs.ix[0, 0])
rs = df.ne(df)
self.assert_(rs.ix[0, 0])
rs = df.gt(df)
self.assert_(not rs.ix[0, 0])
self.assertFalse(rs.ix[0, 0])
rs = df.lt(df)
self.assert_(not rs.ix[0, 0])
self.assertFalse(rs.ix[0, 0])
rs = df.ge(df)
self.assert_(not rs.ix[0, 0])
self.assertFalse(rs.ix[0, 0])
rs = df.le(df)
self.assert_(not rs.ix[0, 0])
self.assertFalse(rs.ix[0, 0])



Expand All @@ -5169,14 +5169,14 @@ def _test_seq(df, idx_ser, col_ser):
df = DataFrame({'a': arr})
df2 = DataFrame({'a': arr2})
rs = df.gt(df2)
self.assert_(not rs.values.any())
self.assertFalse(rs.values.any())
rs = df.ne(df2)
self.assert_(rs.values.all())

arr3 = np.array([2j, np.nan, None])
df3 = DataFrame({'a': arr3})
rs = df3.gt(2j)
self.assert_(not rs.values.any())
self.assertFalse(rs.values.any())

# corner, dtype=object
df1 = DataFrame({'col': ['foo', np.nan, 'bar']})
Expand Down Expand Up @@ -8400,7 +8400,7 @@ def test_truncate_copy(self):
index = self.tsframe.index
truncated = self.tsframe.truncate(index[5], index[10])
truncated.values[:] = 5.
self.assert_(not (self.tsframe.values[5:11] == 5).any())
self.assertFalse((self.tsframe.values[5:11] == 5).any())

def test_xs(self):
idx = self.frame.index[5]
Expand Down Expand Up @@ -10499,13 +10499,13 @@ def test_clip(self):
median = self.frame.median().median()

capped = self.frame.clip_upper(median)
self.assert_(not (capped.values > median).any())
self.assertFalse((capped.values > median).any())

floored = self.frame.clip_lower(median)
self.assert_(not (floored.values < median).any())
self.assertFalse((floored.values < median).any())

double = self.frame.clip(upper=median, lower=median)
self.assert_(not (double.values != median).any())
self.assertFalse((double.values != median).any())

def test_dataframe_clip(self):

Expand Down Expand Up @@ -10536,7 +10536,7 @@ def test_get_X_columns(self):
['a', 'b', 'e'])

def test_is_mixed_type(self):
self.assert_(not self.frame._is_mixed_type)
self.assertFalse(self.frame._is_mixed_type)
self.assert_(self.mixed_frame._is_mixed_type)

def test_get_numeric_data(self):
Expand Down Expand Up @@ -11787,7 +11787,7 @@ def test_constructor_frame_copy(self):
cop = DataFrame(self.frame, copy=True)
cop['A'] = 5
self.assert_((cop['A'] == 5).all())
self.assert_(not (self.frame['A'] == 5).all())
self.assertFalse((self.frame['A'] == 5).all())

def test_constructor_ndarray_copy(self):
df = DataFrame(self.frame.values)
Expand All @@ -11797,15 +11797,15 @@ def test_constructor_ndarray_copy(self):

df = DataFrame(self.frame.values, copy=True)
self.frame.values[6] = 6
self.assert_(not (df.values[6] == 6).all())
self.assertFalse((df.values[6] == 6).all())

def test_constructor_series_copy(self):
series = self.frame._series

df = DataFrame({'A': series['A']})
df['A'][:] = 5

self.assert_(not (series['A'] == 5).all())
self.assertFalse((series['A'] == 5).all())

def test_constructor_compound_dtypes(self):
# GH 5191
Expand Down Expand Up @@ -11938,7 +11938,7 @@ def test_consolidate_inplace(self):

def test_as_matrix_consolidate(self):
self.frame['E'] = 7.
self.assert_(not self.frame._data.is_consolidated())
self.assertFalse(self.frame._data.is_consolidated())
_ = self.frame.as_matrix()
self.assert_(self.frame._data.is_consolidated())

Expand Down Expand Up @@ -12365,8 +12365,8 @@ def __nonzero__(self):
r0 = getattr(all_na, name)(axis=0)
r1 = getattr(all_na, name)(axis=1)
if name == 'any':
self.assert_(not r0.any())
self.assert_(not r1.any())
self.assertFalse(r0.any())
self.assertFalse(r1.any())
else:
self.assert_(r0.all())
self.assert_(r1.all())
Expand Down
14 changes: 7 additions & 7 deletions pandas/tests/test_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1148,15 +1148,15 @@ def test_equals(self):
self.assert_(s1.equals(s2))

s1[1] = 99
self.assert_(not s1.equals(s2))
self.assertFalse(s1.equals(s2))

# NaNs compare as equal
s1 = pd.Series([1, np.nan, 3, np.nan], index=[0, 2, 1, 3])
s2 = s1.copy()
self.assert_(s1.equals(s2))

s2[0] = 9.9
self.assert_(not s1.equals(s2))
self.assertFalse(s1.equals(s2))

idx = MultiIndex.from_tuples([(0, 'a'), (1, 'b'), (2, 'c')])
s1 = Series([1, 2, np.nan], index=idx)
Expand All @@ -1179,22 +1179,22 @@ def test_equals(self):
self.assert_(df1['diff'].equals(df2['diff']))
self.assert_(df1['bool'].equals(df2['bool']))
self.assert_(df1.equals(df2))
self.assert_(not df1.equals(object))
self.assertFalse(df1.equals(object))

# different dtype
different = df1.copy()
different['floats'] = different['floats'].astype('float32')
self.assert_(not df1.equals(different))
self.assertFalse(df1.equals(different))

# different index
different_index = -index
different = df2.set_index(different_index)
self.assert_(not df1.equals(different))
self.assertFalse(df1.equals(different))

# different columns
different = df2.copy()
different.columns = df2.columns[::-1]
self.assert_(not df1.equals(different))
self.assertFalse(df1.equals(different))

# DatetimeIndex
index = pd.date_range('2000-1-1', periods=10, freq='T')
Expand All @@ -1208,7 +1208,7 @@ def test_equals(self):
self.assert_(df3.equals(df2))

df2 = df1.set_index(['floats'], append=True)
self.assert_(not df3.equals(df2))
self.assertFalse(df3.equals(df2))

# NaN in index
df3 = df1.set_index(['floats'], append=True)
Expand Down
26 changes: 13 additions & 13 deletions pandas/tests/test_graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ def test_ts_area_lim(self):
ax = self.ts.plot(kind='area', stacked=False)
xmin, xmax = ax.get_xlim()
lines = ax.get_lines()
self.assertEqual(xmin, lines[0].get_data(orig=False)[0][0])
self.assertEqual(xmin, lines[0].get_data(orig=False)[0][0])
self.assertEqual(xmax, lines[0].get_data(orig=False)[0][-1])

def test_line_area_nan_series(self):
Expand Down Expand Up @@ -1023,13 +1023,13 @@ def test_area_lim(self):
xmin, xmax = ax.get_xlim()
ymin, ymax = ax.get_ylim()
lines = ax.get_lines()
self.assertEqual(xmin, lines[0].get_data()[0][0])
self.assertEqual(xmax, lines[0].get_data()[0][-1])
self.assertEqual(ymin, 0)
self.assertEqual(xmin, lines[0].get_data()[0][0])
self.assertEqual(xmax, lines[0].get_data()[0][-1])
self.assertEqual(ymin, 0)

ax = _check_plot_works(neg_df.plot, kind='area', stacked=stacked)
ymin, ymax = ax.get_ylim()
self.assertEqual(ymax, 0)
self.assertEqual(ymax, 0)

@slow
def test_bar_colors(self):
Expand Down Expand Up @@ -1471,7 +1471,7 @@ def test_hist(self):
df = DataFrame(randn(100, 3))
_check_plot_works(df.hist)
axes = df.hist(grid=False)
self.assert_(not axes[1, 1].get_visible())
self.assertFalse(axes[1, 1].get_visible())

df = DataFrame(randn(100, 1))
_check_plot_works(df.hist)
Expand Down Expand Up @@ -1576,7 +1576,7 @@ def scat2(x, y, by=None, ax=None, figsize=None):
def test_andrews_curves(self):
from pandas.tools.plotting import andrews_curves
from matplotlib import cm

df = self.iris

_check_plot_works(andrews_curves, df, 'Name')
Expand All @@ -1601,15 +1601,15 @@ def test_andrews_curves(self):
ax = andrews_curves(df, 'Name', color=colors)
handles, labels = ax.get_legend_handles_labels()
self._check_colors(handles, linecolors=colors)

with tm.assert_produces_warning(FutureWarning):
andrews_curves(data=df, class_column='Name')

@slow
def test_parallel_coordinates(self):
from pandas.tools.plotting import parallel_coordinates
from matplotlib import cm

df = self.iris

_check_plot_works(parallel_coordinates, df, 'Name')
Expand All @@ -1634,7 +1634,7 @@ def test_parallel_coordinates(self):
ax = parallel_coordinates(df, 'Name', color=colors)
handles, labels = ax.get_legend_handles_labels()
self._check_colors(handles, linecolors=colors)

with tm.assert_produces_warning(FutureWarning):
parallel_coordinates(data=df, class_column='Name')
with tm.assert_produces_warning(FutureWarning):
Expand Down Expand Up @@ -1845,7 +1845,7 @@ def test_area_colors(self):
poly = [o for o in ax.get_children() if isinstance(o, PolyCollection)]
self._check_colors(poly, facecolors=rgba_colors)
tm.close()

ax = df.plot(kind='area', colormap=cm.jet)
rgba_colors = lmap(cm.jet, np.linspace(0, 1, len(df)))
self._check_colors(ax.get_lines(), linecolors=rgba_colors)
Expand Down Expand Up @@ -1920,7 +1920,7 @@ def test_hexbin_basic(self):
# hexbin should have 2 axes in the figure, 1 for plotting and another is colorbar
self.assertEqual(len(axes[0].figure.axes), 2)
# return value is single axes
self._check_axes_shape(axes, axes_num=1, layout=(1, ))
self._check_axes_shape(axes, axes_num=1, layout=(1, ))


@slow
Expand Down Expand Up @@ -2081,7 +2081,7 @@ def test_errorbar_with_partial_columns(self):
df_err = DataFrame(d_err)
for err in [d_err, df_err]:
ax = _check_plot_works(df.plot, yerr=err)
self._check_has_errorbars(ax, xerr=0, yerr=1)
self._check_has_errorbars(ax, xerr=0, yerr=1)

@slow
def test_errorbar_timeseries(self):
Expand Down
Loading