Skip to content

CLN: Deprecation of assert_ #7164

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
6 changes: 3 additions & 3 deletions pandas/io/tests/test_cparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,21 +236,21 @@ def _make_reader(**kwds):
self.assertEqual(result[0].dtype, 'S5')

ex_values = np.array(['a', 'aa', 'aaa', 'aaaa', 'aaaaa'], dtype='S5')
self.assert_((result[0] == ex_values).all())
self.assertTrue((result[0] == ex_values).all())
self.assertEqual(result[1].dtype, 'i4')

reader = _make_reader(dtype='S4')
result = reader.read()
self.assertEqual(result[0].dtype, 'S4')
ex_values = np.array(['a', 'aa', 'aaa', 'aaaa', 'aaaa'], dtype='S4')
self.assert_((result[0] == ex_values).all())
self.assertTrue((result[0] == ex_values).all())
self.assertEqual(result[1].dtype, 'S4')

reader = _make_reader(dtype='S4', as_recarray=True)
result = reader.read()
self.assertEqual(result['0'].dtype, 'S4')
ex_values = np.array(['a', 'aa', 'aaa', 'aaaa', 'aaaa'], dtype='S4')
self.assert_((result['0'] == ex_values).all())
self.assertTrue((result['0'] == ex_values).all())
self.assertEqual(result['1'].dtype, 'S4')

def test_pass_dtype(self):
Expand Down
4 changes: 2 additions & 2 deletions pandas/io/tests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def test_get_data_multiple_symbols_two_dates(self):
def test_get_date_ret_index(self):
pan = web.get_data_yahoo(['GE', 'INTC', 'IBM'], '1977', '1987',
ret_index=True)
self.assert_(hasattr(pan, 'Ret_Index'))
self.assertTrue(hasattr(pan, 'Ret_Index'))
if hasattr(pan, 'Ret_Index') and hasattr(pan.Ret_Index, 'INTC'):
tstamp = pan.Ret_Index.INTC.first_valid_index()
result = pan.Ret_Index.ix[tstamp]['INTC']
Expand Down Expand Up @@ -358,7 +358,7 @@ def test_get_put_data_warning(self):
class TestDataReader(tm.TestCase):
def test_is_s3_url(self):
from pandas.io.common import _is_s3_url
self.assert_(_is_s3_url("s3://pandas/somethingelse.com"))
self.assertTrue(_is_s3_url("s3://pandas/somethingelse.com"))

@network
def test_read_yahoo(self):
Expand Down
6 changes: 3 additions & 3 deletions pandas/io/tests/test_date_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def setUp(self):

def test_parse_date_time(self):
result = conv.parse_date_time(self.dates, self.times)
self.assert_((result == self.expected).all())
self.assertTrue((result == self.expected).all())

data = """\
date, time, a, b
Expand All @@ -66,7 +66,7 @@ def test_parse_date_time(self):
def test_parse_date_fields(self):
result = conv.parse_date_fields(self.years, self.months, self.days)
expected = np.array([datetime(2007, 1, 3), datetime(2008, 2, 4)])
self.assert_((result == expected).all())
self.assertTrue((result == expected).all())

data = "year, month, day, a\n 2001 , 01 , 10 , 10.\n 2001 , 02 , 1 , 11."
datecols = {'ymd': [0, 1, 2]}
Expand All @@ -79,7 +79,7 @@ def test_parse_date_fields(self):
def test_datetime_six_col(self):
result = conv.parse_all_fields(self.years, self.months, self.days,
self.hours, self.minutes, self.seconds)
self.assert_((result == self.expected).all())
self.assertTrue((result == self.expected).all())

data = """\
year, month, day, hour, minute, second, a, b
Expand Down
4 changes: 2 additions & 2 deletions pandas/io/tests/test_excel.py
Original file line number Diff line number Diff line change
Expand Up @@ -1223,8 +1223,8 @@ def write_cells(self, *args, **kwargs):

def check_called(func):
func()
self.assert_(len(called_save) >= 1)
self.assert_(len(called_write_cells) >= 1)
self.assertTrue(len(called_save) >= 1)
self.assertTrue(len(called_write_cells) >= 1)
del called_save[:]
del called_write_cells[:]

Expand Down
2 changes: 1 addition & 1 deletion pandas/io/tests/test_ga.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_remove_token_store(self):
fh.write('test')

reset_default_token_store()
self.assert_(not os.path.exists(auth.DEFAULT_TOKEN_FILE))
self.assertFalse(os.path.exists(auth.DEFAULT_TOKEN_FILE))

@slow
@network
Expand Down
2 changes: 1 addition & 1 deletion pandas/io/tests/test_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ def test_multiple_matches(self):
url = 'http://code.google.com/p/pythonxy/wiki/StandardPlugins'
dfs = self.read_html(url, match='Python',
attrs={'class': 'wikitable'})
self.assert_(len(dfs) > 1)
self.assertTrue(len(dfs) > 1)

@network
def test_pythonxy_plugins_table(self):
Expand Down
2 changes: 1 addition & 1 deletion pandas/io/tests/test_json/test_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def _check_orient(df, orient, dtype=None, numpy=False,
if orient == "records":
# index is not captured in this orientation
assert_almost_equal(df.values, unser.values)
self.assert_(df.columns.equals(unser.columns))
self.assertTrue(df.columns.equals(unser.columns))
elif orient == "values":
# index and cols are not captured in this orientation
assert_almost_equal(df.values, unser.values)
Expand Down
24 changes: 12 additions & 12 deletions pandas/io/tests/test_json/test_ujson.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def test_encodeDoubleTinyExponential(self):
num = -1e-45
self.assertEqual(num, ujson.decode(ujson.encode(num)))
num = -1e-145
self.assert_(np.allclose(num, ujson.decode(ujson.encode(num))))
self.assertTrue(np.allclose(num, ujson.decode(ujson.encode(num))))

def test_encodeDictWithUnicodeKeys(self):
input = {u("key1"): u("value1"), u("key1"):
Expand Down Expand Up @@ -1315,39 +1315,39 @@ def testIndex(self):

# column indexed
outp = Index(ujson.decode(ujson.encode(i)))
self.assert_(i.equals(outp))
self.assertTrue(i.equals(outp))

outp = Index(ujson.decode(ujson.encode(i), numpy=True))
self.assert_(i.equals(outp))
self.assertTrue(i.equals(outp))

dec = _clean_dict(ujson.decode(ujson.encode(i, orient="split")))
outp = Index(**dec)
self.assert_(i.equals(outp))
self.assertTrue(i.equals(outp))
self.assertTrue(i.name == outp.name)

dec = _clean_dict(ujson.decode(ujson.encode(i, orient="split"),
numpy=True))
outp = Index(**dec)
self.assert_(i.equals(outp))
self.assertTrue(i.equals(outp))
self.assertTrue(i.name == outp.name)

outp = Index(ujson.decode(ujson.encode(i, orient="values")))
self.assert_(i.equals(outp))
self.assertTrue(i.equals(outp))

outp = Index(ujson.decode(ujson.encode(i, orient="values"), numpy=True))
self.assert_(i.equals(outp))
self.assertTrue(i.equals(outp))

outp = Index(ujson.decode(ujson.encode(i, orient="records")))
self.assert_(i.equals(outp))
self.assertTrue(i.equals(outp))

outp = Index(ujson.decode(ujson.encode(i, orient="records"), numpy=True))
self.assert_(i.equals(outp))
self.assertTrue(i.equals(outp))

outp = Index(ujson.decode(ujson.encode(i, orient="index")))
self.assert_(i.equals(outp))
self.assertTrue(i.equals(outp))

outp = Index(ujson.decode(ujson.encode(i, orient="index"), numpy=True))
self.assert_(i.equals(outp))
self.assertTrue(i.equals(outp))

def test_datetimeindex(self):
from pandas.tseries.index import date_range
Expand All @@ -1357,7 +1357,7 @@ def test_datetimeindex(self):
encoded = ujson.encode(rng, date_unit='ns')
decoded = DatetimeIndex(np.array(ujson.decode(encoded)))

self.assert_(rng.equals(decoded))
self.assertTrue(rng.equals(decoded))

ts = Series(np.random.randn(len(rng)), index=rng)
decoded = Series(ujson.decode(ujson.encode(ts, date_unit='ns')))
Expand Down
18 changes: 9 additions & 9 deletions pandas/io/tests/test_packers.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def test_numpy_scalar_float(self):
def test_numpy_scalar_complex(self):
x = np.complex64(np.random.rand() + 1j * np.random.rand())
x_rec = self.encode_decode(x)
self.assert_(np.allclose(x, x_rec))
self.assertTrue(np.allclose(x, x_rec))

def test_scalar_float(self):
x = np.random.rand()
Expand All @@ -113,7 +113,7 @@ def test_scalar_float(self):
def test_scalar_complex(self):
x = np.random.rand() + 1j * np.random.rand()
x_rec = self.encode_decode(x)
self.assert_(np.allclose(x, x_rec))
self.assertTrue(np.allclose(x, x_rec))

def test_list_numpy_float(self):
x = [np.float32(np.random.rand()) for i in range(5)]
Expand All @@ -128,7 +128,7 @@ def test_list_numpy_float_complex(self):
[np.complex128(np.random.rand() + 1j * np.random.rand())
for i in range(5)]
x_rec = self.encode_decode(x)
self.assert_(np.allclose(x, x_rec))
self.assertTrue(np.allclose(x, x_rec))

def test_list_float(self):
x = [np.random.rand() for i in range(5)]
Expand All @@ -139,7 +139,7 @@ def test_list_float_complex(self):
x = [np.random.rand() for i in range(5)] + \
[(np.random.rand() + 1j * np.random.rand()) for i in range(5)]
x_rec = self.encode_decode(x)
self.assert_(np.allclose(x, x_rec))
self.assertTrue(np.allclose(x, x_rec))

def test_dict_float(self):
x = {'foo': 1.0, 'bar': 2.0}
Expand Down Expand Up @@ -244,23 +244,23 @@ def test_basic_index(self):

for s, i in self.d.items():
i_rec = self.encode_decode(i)
self.assert_(i.equals(i_rec))
self.assertTrue(i.equals(i_rec))

# datetime with no freq (GH5506)
i = Index([Timestamp('20130101'),Timestamp('20130103')])
i_rec = self.encode_decode(i)
self.assert_(i.equals(i_rec))
self.assertTrue(i.equals(i_rec))

# datetime with timezone
i = Index([Timestamp('20130101 9:00:00'),Timestamp('20130103 11:00:00')]).tz_localize('US/Eastern')
i_rec = self.encode_decode(i)
self.assert_(i.equals(i_rec))
self.assertTrue(i.equals(i_rec))

def test_multi_index(self):

for s, i in self.mi.items():
i_rec = self.encode_decode(i)
self.assert_(i.equals(i_rec))
self.assertTrue(i.equals(i_rec))

def test_unicode(self):
i = tm.makeUnicodeIndex(100)
Expand All @@ -269,7 +269,7 @@ def test_unicode(self):
self.assertRaises(UnicodeEncodeError, self.encode_decode, i)

#i_rec = self.encode_decode(i)
#self.assert_(i.equals(i_rec))
#self.assertTrue(i.equals(i_rec))


class TestSeries(TestPackers):
Expand Down
28 changes: 14 additions & 14 deletions pandas/io/tests/test_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ def test_malformed(self):
try:
df = self.read_table(
StringIO(data), sep=',', header=1, comment='#')
self.assert_(False)
self.assertTrue(False)
except Exception as inst:
self.assertIn('Expected 3 fields in line 4, saw 5', str(inst))

Expand All @@ -551,7 +551,7 @@ def test_malformed(self):
df = self.read_table(
StringIO(data), sep=',', header=1, comment='#',
skip_footer=1)
self.assert_(False)
self.assertTrue(False)
except Exception as inst:
self.assertIn('Expected 3 fields in line 4, saw 5', str(inst))

Expand All @@ -569,7 +569,7 @@ def test_malformed(self):
header=1, comment='#', iterator=True, chunksize=1,
skiprows=[2])
df = it.read(5)
self.assert_(False)
self.assertTrue(False)
except Exception as inst:
self.assertIn('Expected 3 fields in line 6, saw 5', str(inst))

Expand All @@ -588,7 +588,7 @@ def test_malformed(self):
skiprows=[2])
df = it.read(1)
it.read(2)
self.assert_(False)
self.assertTrue(False)
except Exception as inst:
self.assertIn('Expected 3 fields in line 6, saw 5', str(inst))

Expand All @@ -607,7 +607,7 @@ def test_malformed(self):
skiprows=[2])
df = it.read(1)
it.read()
self.assert_(False)
self.assertTrue(False)
except Exception as inst:
self.assertIn('Expected 3 fields in line 6, saw 5', str(inst))

Expand Down Expand Up @@ -1134,7 +1134,7 @@ def test_infer_index_col(self):
baz,7,8,9
"""
data = self.read_csv(StringIO(data))
self.assert_(data.index.equals(Index(['foo', 'bar', 'baz'])))
self.assertTrue(data.index.equals(Index(['foo', 'bar', 'baz'])))

def test_read_nrows(self):
df = self.read_csv(StringIO(self.data1), nrows=3)
Expand Down Expand Up @@ -1912,7 +1912,7 @@ def convert_score(x):
result = self.read_csv(fh, converters={'score': convert_score,
'days': convert_days},
na_values=['', None])
self.assert_(pd.isnull(result['days'][1]))
self.assertTrue(pd.isnull(result['days'][1]))

fh = StringIO(csv)
result2 = self.read_csv(fh, converters={'score': convert_score,
Expand Down Expand Up @@ -2177,7 +2177,7 @@ def test_sniff_delimiter(self):
baz|7|8|9
"""
data = self.read_csv(StringIO(text), index_col=0, sep=None)
self.assert_(data.index.equals(Index(['foo', 'bar', 'baz'])))
self.assertTrue(data.index.equals(Index(['foo', 'bar', 'baz'])))

data2 = self.read_csv(StringIO(text), index_col=0, delimiter='|')
tm.assert_frame_equal(data, data2)
Expand Down Expand Up @@ -2378,7 +2378,7 @@ def test_fwf_regression(self):

for c in df.columns:
res = df.loc[:,c]
self.assert_(len(res))
self.assertTrue(len(res))

def test_fwf_compression(self):
try:
Expand Down Expand Up @@ -2577,7 +2577,7 @@ def test_malformed(self):
try:
df = self.read_table(
StringIO(data), sep=',', header=1, comment='#')
self.assert_(False)
self.assertTrue(False)
except Exception as inst:
self.assertIn('Expected 3 fields in line 4, saw 5', str(inst))

Expand All @@ -2594,7 +2594,7 @@ def test_malformed(self):
df = self.read_table(
StringIO(data), sep=',', header=1, comment='#',
skip_footer=1)
self.assert_(False)
self.assertTrue(False)
except Exception as inst:
self.assertIn('Expected 3 fields in line 4, saw 5', str(inst))

Expand All @@ -2612,7 +2612,7 @@ def test_malformed(self):
header=1, comment='#', iterator=True, chunksize=1,
skiprows=[2])
df = it.read(5)
self.assert_(False)
self.assertTrue(False)
except Exception as inst:
self.assertIn('Expected 3 fields in line 6, saw 5', str(inst))

Expand All @@ -2631,7 +2631,7 @@ def test_malformed(self):
skiprows=[2])
df = it.read(1)
it.read(2)
self.assert_(False)
self.assertTrue(False)
except Exception as inst:
self.assertIn('Expected 3 fields in line 6, saw 5', str(inst))

Expand All @@ -2650,7 +2650,7 @@ def test_malformed(self):
skiprows=[2])
df = it.read(1)
it.read()
self.assert_(False)
self.assertTrue(False)
except Exception as inst:
self.assertIn('Expected 3 fields in line 6, saw 5', str(inst))

Expand Down
2 changes: 1 addition & 1 deletion pandas/io/tests/test_pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def setUp(self):

def compare_element(self, typ, result, expected):
if isinstance(expected,Index):
self.assert_(expected.equals(result))
self.assertTrue(expected.equals(result))
return

if typ.startswith('sp_'):
Expand Down
Loading