Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
pandas failures 27.9.17
$ grep -a '\(^E *[A-Z][a-zA-Z]*Error:\)\|\(^E *AssertionError$\)\|\(^E *MemoryError\)\|\(^E *Bad\)\|\(^E *Failed:\)' ../test_pandas.txt |cut -c 5- |cut -f1,2 -d: | sed -e's/ */ /' | sort |uniq -c |sort -n -r
2 OperationalError: database table is locked
2 Failed: DID NOT RAISE <type 'exceptions.Exception'>
2 BadZipfile: File is not a zip file
1 ValueError: ('year must be in 1..9999', 0)
1 TypeError: expected a readable buffer object
1 SettingWithCopyError:
1 BadMove: testing
1 BadMove: test
1 AssertionError: TypeError not raised.
1 AssertionError: ""quoting" must be an integer" does not match "expected integer, got str object"
1 AssertionError: "can't multiply sequence by non-int" does not match "unsupported operand type(s) for *
1 AssertionError: assert 'C0 1 days...9 0.411195 ' == ' '
$ ../pypy-test/bin/python -mpytest --skip-slow --skip-network pandas --lf
============================================================ test session starts ============================================================
platform linux2 -- Python 2.7.13[pypy-5.9.0-alpha], pytest-3.2.0, py-1.4.34, pluggy-0.4.0
rootdir: /home/matti/pypy_stuff/pandas, inifile: setup.cfg
plugins: xdist-1.18.2
collected 11683 items / 13 skipped
run-last-failure: rerun previous 19 failures
pandas/tests/frame/test_period.py .
pandas/tests/groupby/test_groupby.py .
pandas/tests/indexes/test_base.py .
pandas/tests/indexes/timedeltas/test_timedelta.py F
pandas/tests/indexing/test_chaining_and_caching.py F
pandas/tests/io/test_pickle.py FF
pandas/tests/io/test_sql.py .E.E
pandas/tests/io/msgpack/test_buffer.py F
pandas/tests/io/parser/test_parsers.py FFF
pandas/tests/io/sas/test_sas7bdat.py .
pandas/tests/scalar/test_interval.py F
pandas/tests/scalar/test_nat.py F
pandas/tests/util/test_util.py FFF
================================================================== ERRORS ===================================================================
____________________________________________ ERROR at teardown of TestSQLiteFallback.test_dtype _____________________________________________
self = <pandas.tests.io.test_sql.TestSQLiteFallback object at 0x000000000dbc5830>
method = <bound method TestSQLiteFallback.test_dtype of <pandas.tests.io.test_sql.TestSQLiteFallback object at 0x000000000dbc5830>>
def teardown_method(self, method):
for tbl in self._get_all_tables():
> self.drop_table(tbl)
pandas/tests/io/test_sql.py:183:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pandas/tests/io/test_sql.py:212: in drop_table
sql._get_valid_sqlite_name(table_name))
../pypy/lib_pypy/_sqlite3.py:400: in execute
return cur.execute(*args)
../pypy/lib_pypy/_sqlite3.py:728: in wrapper
return func(self, *args, **kwargs)
../pypy/lib_pypy/_sqlite3.py:895: in execute
return self.__execute(False, sql, [params])
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <_sqlite3.Cursor object at 0x000000000580f088>, multiple = False, sql = 'DROP TABLE IF EXISTS "iris"', many_params = [[]]
def __execute(self, multiple, sql, many_params):
self.__locked = True
self._reset = False
try:
del self.__next_row
except AttributeError:
pass
try:
if not isinstance(sql, basestring):
raise ValueError("operation parameter must be str or unicode")
try:
del self.__description
except AttributeError:
pass
self.__rowcount = -1
self.__statement = self.__connection._statement_cache.get(sql)
if self.__connection._isolation_level is not None:
if self.__statement._type in (
_STMT_TYPE_UPDATE,
_STMT_TYPE_DELETE,
_STMT_TYPE_INSERT,
_STMT_TYPE_REPLACE
):
if not self.__connection._in_transaction:
self.__connection._begin()
elif self.__statement._type == _STMT_TYPE_OTHER:
if self.__connection._in_transaction:
self.__connection.commit()
elif self.__statement._type == _STMT_TYPE_SELECT:
if multiple:
raise ProgrammingError("You cannot execute SELECT "
"statements in executemany().")
for params in many_params:
self.__statement._set_params(params)
# Actually execute the SQL statement
ret = _lib.sqlite3_step(self.__statement._statement)
# PyPy: if we get SQLITE_LOCKED, it's probably because
# one of the cursors created previously is still alive
# and not reset and the operation we're trying to do
# makes Sqlite unhappy about that. In that case, we
# automatically reset all old cursors and try again.
if ret == _lib.SQLITE_LOCKED:
self.__connection._reset_already_committed_statements()
ret = _lib.sqlite3_step(self.__statement._statement)
if ret == _lib.SQLITE_ROW:
if multiple:
raise ProgrammingError("executemany() can only execute DML statements.")
self.__build_row_cast_map()
self.__next_row = self.__fetch_one_row()
elif ret == _lib.SQLITE_DONE:
if not multiple:
self.__statement._reset()
else:
self.__statement._reset()
> raise self.__connection._get_exception(ret)
E OperationalError: database table is locked
../pypy/lib_pypy/_sqlite3.py:868: OperationalError
_________________________________________ ERROR at teardown of TestSQLiteFallback.test_notna_dtype __________________________________________
self = <pandas.tests.io.test_sql.TestSQLiteFallback object at 0x000000000cb9f750>
method = <bound method TestSQLiteFallback.test_notna_dtype of <pandas.tests.io.test_sql.TestSQLiteFallback object at 0x000000000cb9f750>>
def teardown_method(self, method):
for tbl in self._get_all_tables():
> self.drop_table(tbl)
pandas/tests/io/test_sql.py:183:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pandas/tests/io/test_sql.py:212: in drop_table
sql._get_valid_sqlite_name(table_name))
../pypy/lib_pypy/_sqlite3.py:400: in execute
return cur.execute(*args)
../pypy/lib_pypy/_sqlite3.py:728: in wrapper
return func(self, *args, **kwargs)
../pypy/lib_pypy/_sqlite3.py:895: in execute
return self.__execute(False, sql, [params])
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <_sqlite3.Cursor object at 0x000000000cc18e58>, multiple = False, sql = 'DROP TABLE IF EXISTS "iris"', many_params = [[]]
def __execute(self, multiple, sql, many_params):
self.__locked = True
self._reset = False
try:
del self.__next_row
except AttributeError:
pass
try:
if not isinstance(sql, basestring):
raise ValueError("operation parameter must be str or unicode")
try:
del self.__description
except AttributeError:
pass
self.__rowcount = -1
self.__statement = self.__connection._statement_cache.get(sql)
if self.__connection._isolation_level is not None:
if self.__statement._type in (
_STMT_TYPE_UPDATE,
_STMT_TYPE_DELETE,
_STMT_TYPE_INSERT,
_STMT_TYPE_REPLACE
):
if not self.__connection._in_transaction:
self.__connection._begin()
elif self.__statement._type == _STMT_TYPE_OTHER:
if self.__connection._in_transaction:
self.__connection.commit()
elif self.__statement._type == _STMT_TYPE_SELECT:
if multiple:
raise ProgrammingError("You cannot execute SELECT "
"statements in executemany().")
for params in many_params:
self.__statement._set_params(params)
# Actually execute the SQL statement
ret = _lib.sqlite3_step(self.__statement._statement)
# PyPy: if we get SQLITE_LOCKED, it's probably because
# one of the cursors created previously is still alive
# and not reset and the operation we're trying to do
# makes Sqlite unhappy about that. In that case, we
# automatically reset all old cursors and try again.
if ret == _lib.SQLITE_LOCKED:
self.__connection._reset_already_committed_statements()
ret = _lib.sqlite3_step(self.__statement._statement)
if ret == _lib.SQLITE_ROW:
if multiple:
raise ProgrammingError("executemany() can only execute DML statements.")
self.__build_row_cast_map()
self.__next_row = self.__fetch_one_row()
elif ret == _lib.SQLITE_DONE:
if not multiple:
self.__statement._reset()
else:
self.__statement._reset()
> raise self.__connection._get_exception(ret)
E OperationalError: database table is locked
../pypy/lib_pypy/_sqlite3.py:868: OperationalError
================================================================= FAILURES ==================================================================
__________________________________________ TestTimedeltaIndex.test_does_not_convert_mixed_integer ___________________________________________
self = <pandas.tests.indexes.timedeltas.test_timedelta.TestTimedeltaIndex object at 0x00000000061fcfe0>
def test_does_not_convert_mixed_integer(self):
df = tm.makeCustomDataframe(10, 10,
data_gen_f=lambda *args, **kwargs: randn(),
r_idx_type='i', c_idx_type='td')
> assert str(df) == ' '
E AssertionError: assert 'C0 1 days...9 0.411195 ' == ' '
E +
E - C0 1 days 2 days 3 days 4 days 5 days 6 days 7 days \\
E - R0
E - 0 -0.835759 -0.700187 -0.193064 0.852200 -0.073754 -0.761082 -2.722375
E - 1 -0.120977 0.423243 -1.339032 1.269391 -0.513118 0.296654 -1.378912
E - 2 -1.593469 -0.398818 0.043252 0.867683 0.157436 0.418768 0.165580
E - 3 -3.079498 -0.502929 -1.705199 0.471934 -0.731164 0.525357 -0.881689 ...
E
E ...Full output truncated (20 lines hidden), use '-vv' to show
pandas/tests/indexes/timedeltas/test_timedelta.py:305: AssertionError
________________________________________________ TestChaining.test_detect_chained_assignment ________________________________________________
self = <pandas.tests.indexing.test_chaining_and_caching.TestChaining object at 0x0000000006903c90>
def test_detect_chained_assignment(self):
pd.set_option('chained_assignment', 'raise')
# work with the chain
expected = DataFrame([[-5, 1], [-6, 3]], columns=list('AB'))
df = DataFrame(np.arange(4).reshape(2, 2),
columns=list('AB'), dtype='int64')
assert df.is_copy is None
df['A'][0] = -5
df['A'][1] = -6
tm.assert_frame_equal(df, expected)
# test with the chaining
df = DataFrame({'A': Series(range(2), dtype='int64'),
'B': np.array(np.arange(2, 4), dtype=np.float64)})
assert df.is_copy is None
with pytest.raises(com.SettingWithCopyError):
df['A'][0] = -5
with pytest.raises(com.SettingWithCopyError):
df['A'][1] = np.nan
assert df['A'].is_copy is None
# Using a copy (the chain), fails
df = DataFrame({'A': Series(range(2), dtype='int64'),
'B': np.array(np.arange(2, 4), dtype=np.float64)})
with pytest.raises(com.SettingWithCopyError):
df.loc[0]['A'] = -5
# Doc example
df = DataFrame({'a': ['one', 'one', 'two', 'three',
'two', 'one', 'six'],
'c': Series(range(7), dtype='int64')})
assert df.is_copy is None
with pytest.raises(com.SettingWithCopyError):
indexer = df.a.str.startswith('o')
df[indexer]['c'] = 42
expected = DataFrame({'A': [111, 'bbb', 'ccc'], 'B': [1, 2, 3]})
df = DataFrame({'A': ['aaa', 'bbb', 'ccc'], 'B': [1, 2, 3]})
with pytest.raises(com.SettingWithCopyError):
df['A'][0] = 111
with pytest.raises(com.SettingWithCopyError):
df.loc[0]['A'] = 111
df.loc[0, 'A'] = 111
tm.assert_frame_equal(df, expected)
# gh-5475: Make sure that is_copy is picked up reconstruction
df = DataFrame({"A": [1, 2]})
assert df.is_copy is None
with tm.ensure_clean('__tmp__pickle') as path:
df.to_pickle(path)
df2 = pd.read_pickle(path)
df2["B"] = df2["A"]
df2["B"] = df2["A"]
# gh-5597: a spurious raise as we are setting the entire column here
from string import ascii_letters as letters
def random_text(nobs=100):
df = []
for i in range(nobs):
idx = np.random.randint(len(letters), size=2)
idx.sort()
df.append([letters[idx[0]:idx[1]]])
return DataFrame(df, columns=['letters'])
df = random_text(100000)
# Always a copy
x = df.iloc[[0, 1, 2]]
assert x.is_copy is not None
x = df.iloc[[0, 1, 2, 4]]
assert x.is_copy is not None
# Explicitly copy
indexer = df.letters.apply(lambda x: len(x) > 10)
df = df.loc[indexer].copy()
assert df.is_copy is None
df['letters'] = df['letters'].apply(str.lower)
# Implicitly take
df = random_text(100000)
indexer = df.letters.apply(lambda x: len(x) > 10)
df = df.loc[indexer]
assert df.is_copy is not None
df['letters'] = df['letters'].apply(str.lower)
# Implicitly take 2
df = random_text(100000)
indexer = df.letters.apply(lambda x: len(x) > 10)
df = df.loc[indexer]
assert df.is_copy is not None
df.loc[:, 'letters'] = df['letters'].apply(str.lower)
# Should be ok even though it's a copy!
assert df.is_copy is None
df['letters'] = df['letters'].apply(str.lower)
assert df.is_copy is None
df = random_text(100000)
indexer = df.letters.apply(lambda x: len(x) > 10)
df.loc[indexer, 'letters'] = (
df.loc[indexer, 'letters'].apply(str.lower))
# an identical take, so no copy
df = DataFrame({'a': [1]}).dropna()
assert df.is_copy is None
df['a'] += 1
# Inplace ops, originally from:
# http://stackoverflow.com/questions/20508968/series-fillna-in-a-multiindex-dataframe-does-not-fill-is-this-a-bug
a = [12, 23]
b = [123, None]
c = [1234, 2345]
d = [12345, 23456]
tuples = [('eyes', 'left'), ('eyes', 'right'), ('ears', 'left'),
('ears', 'right')]
events = {('eyes', 'left'): a,
('eyes', 'right'): b,
('ears', 'left'): c,
('ears', 'right'): d}
multiind = MultiIndex.from_tuples(tuples, names=['part', 'side'])
zed = DataFrame(events, index=['a', 'b'], columns=multiind)
with pytest.raises(com.SettingWithCopyError):
zed['eyes']['right'].fillna(value=555, inplace=True)
df = DataFrame(np.random.randn(10, 4))
s = df.iloc[:, 0].sort_values()
tm.assert_series_equal(s, df.iloc[:, 0].sort_values())
tm.assert_series_equal(s, df[0].sort_values())
# see gh-6025: false positives
df = DataFrame({'column1': ['a', 'a', 'a'], 'column2': [4, 8, 9]})
str(df)
df['column1'] = df['column1'] + 'b'
str(df)
df = df[df['column2'] != 8]
str(df)
> df['column1'] = df['column1'] + 'c'
pandas/tests/indexing/test_chaining_and_caching.py:292:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pandas/core/frame.py:2463: in __setitem__
self._set_item(key, value)
pandas/core/frame.py:2536: in _set_item
self._check_setitem_copy()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = column1 column2
0 abc 4
2 abc 9, stacklevel = 4
t = '\nA value is trying to be set on a copy of a slice from a DataFrame.\nTry using .loc[row_indexer,col_indexer] = value... the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy'
force = False
def _check_setitem_copy(self, stacklevel=4, t='setting', force=False):
"""
Parameters
----------
stacklevel : integer, default 4
the level to show of the stack when the error is output
t : string, the type of setting error
force : boolean, default False
if True, then force showing an error
validate if we are doing a settitem on a chained copy.
If you call this function, be sure to set the stacklevel such that the
user will see the error *at the level of setting*
It is technically possible to figure out that we are setting on
a copy even WITH a multi-dtyped pandas object. In other words, some
blocks may be views while other are not. Currently _is_view will ALWAYS
return False for multi-blocks to avoid having to handle this case.
df = DataFrame(np.arange(0,9), columns=['count'])
df['group'] = 'b'
# This technically need not raise SettingWithCopy if both are view
# (which is not # generally guaranteed but is usually True. However,
# this is in general not a good practice and we recommend using .loc.
df.iloc[0:5]['group'] = 'a'
"""
if force or self.is_copy:
value = config.get_option('mode.chained_assignment')
if value is None:
return
# see if the copy is not actually refererd; if so, then disolve
# the copy weakref
try:
gc.collect(2)
if not gc.get_referents(self.is_copy()):
self.is_copy = None
return
except:
pass
# we might be a false positive
try:
if self.is_copy().shape == self.shape:
self.is_copy = None
return
except:
pass
# a custom message
if isinstance(self.is_copy, string_types):
t = self.is_copy
elif t == 'referant':
t = ("\n"
"A value is trying to be set on a copy of a slice from a "
"DataFrame\n\n"
"See the caveats in the documentation: "
"http://pandas.pydata.org/pandas-docs/stable/"
"indexing.html#indexing-view-versus-copy"
)
else:
t = ("\n"
"A value is trying to be set on a copy of a slice from a "
"DataFrame.\n"
"Try using .loc[row_indexer,col_indexer] = value "
"instead\n\nSee the caveats in the documentation: "
"http://pandas.pydata.org/pandas-docs/stable/"
"indexing.html#indexing-view-versus-copy"
)
if value == 'raise':
> raise SettingWithCopyError(t)
E SettingWithCopyError:
E A value is trying to be set on a copy of a slice from a DataFrame.
E Try using .loc[row_indexer,col_indexer] = value instead
E
E See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
pandas/core/generic.py:2026: SettingWithCopyError
__________________________________________________ TestCompression.test_read_explicit[zip] __________________________________________________
self = <pandas.tests.io.test_pickle.TestCompression object at 0x00000000089dd2b8>, compression = 'zip'
get_random_path = '__nXtgiljGUt__.pickle'
@pytest.mark.parametrize('compression', [None, 'gzip', 'bz2', 'xz', "zip"])
def test_read_explicit(self, compression, get_random_path):
# issue 11666
if compression == 'xz':
tm._skip_if_no_lzma()
base = get_random_path
path1 = base + ".raw"
path2 = base + ".compressed"
with tm.ensure_clean(path1) as p1, tm.ensure_clean(path2) as p2:
df = tm.makeDataFrame()
# write to uncompressed file
df.to_pickle(p1, compression=None)
# compress
self.compress_file(p1, p2, compression=compression)
# read compressed file
> df2 = pd.read_pickle(p2, compression=compression)
pandas/tests/io/test_pickle.py:473:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pandas/io/pickle.py:110: in read_pickle
return try_read(path)
pandas/io/pickle.py:108: in try_read
lambda f: pc.load(f, encoding=encoding, compat=True))
pandas/io/pickle.py:82: in read_wrapper
is_text=False)
pandas/io/common.py:363: in _get_handle
zip_file = zipfile.ZipFile(path_or_buf)
../pypy/lib-python/2.7/zipfile.py:774: in __init__
self._RealGetContents()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <zipfile.ZipFile object at 0x000000000b5b8410>
def _RealGetContents(self):
"""Read in the table of contents for the ZIP file."""
fp = self.fp
try:
endrec = _EndRecData(fp)
except IOError:
raise BadZipfile("File is not a zip file")
if not endrec:
> raise BadZipfile, "File is not a zip file"
E BadZipfile: File is not a zip file
../pypy/lib-python/2.7/zipfile.py:817: BadZipfile
___________________________________________________ TestCompression.test_read_infer[.zip] ___________________________________________________
self = <pandas.tests.io.test_pickle.TestCompression object at 0x000000000d952020>, ext = '.zip', get_random_path = '__FRyajdQUNa__.pickle'
@pytest.mark.parametrize('ext', ['', '.gz', '.bz2', '.xz', '.zip',
'.no_compress'])
def test_read_infer(self, ext, get_random_path):
if ext == '.xz':
tm._skip_if_no_lzma()
base = get_random_path
path1 = base + ".raw"
path2 = base + ext
compression = None
for c in self._compression_to_extension:
if self._compression_to_extension[c] == ext:
compression = c
break
with tm.ensure_clean(path1) as p1, tm.ensure_clean(path2) as p2:
df = tm.makeDataFrame()
# write to uncompressed file
df.to_pickle(p1, compression=None)
# compress
self.compress_file(p1, p2, compression=compression)
# read compressed file by inferred compression method
> df2 = pd.read_pickle(p2)
pandas/tests/io/test_pickle.py:502:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pandas/io/pickle.py:110: in read_pickle
return try_read(path)
pandas/io/pickle.py:108: in try_read
lambda f: pc.load(f, encoding=encoding, compat=True))
pandas/io/pickle.py:82: in read_wrapper
is_text=False)
pandas/io/common.py:363: in _get_handle
zip_file = zipfile.ZipFile(path_or_buf)
../pypy/lib-python/2.7/zipfile.py:774: in __init__
self._RealGetContents()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <zipfile.ZipFile object at 0x000000000aa9f948>
def _RealGetContents(self):
"""Read in the table of contents for the ZIP file."""
fp = self.fp
try:
endrec = _EndRecData(fp)
except IOError:
raise BadZipfile("File is not a zip file")
if not endrec:
> raise BadZipfile, "File is not a zip file"
E BadZipfile: File is not a zip file
../pypy/lib-python/2.7/zipfile.py:817: BadZipfile
____________________________________________________________ test_unpack_buffer _____________________________________________________________
def test_unpack_buffer():
from array import array
buf = array('b')
frombytes(buf, packb((b'foo', b'bar')))
> obj = unpackb(buf, use_list=1)
pandas/tests/io/msgpack/test_buffer.py:11:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> PyObject_AsReadBuffer(packed, <const void**>&buf, &buf_len)
E TypeError: expected a readable buffer object
pandas/io/msgpack/_unpacker.pyx:124: TypeError
_____________________________________________ TestCParserHighMemory.test_iteration_open_handle ______________________________________________
self = <pandas.tests.io.parser.test_parsers.TestCParserHighMemory object at 0x000000000f8a7c20>
def test_iteration_open_handle(self):
if PY3:
pytest.skip(
"won't work in Python 3 {0}".format(sys.version_info))
with tm.ensure_clean() as path:
with open(path, 'wb') as f:
f.write('AAA\nBBB\nCCC\nDDD\nEEE\nFFF\nGGG')
with open(path, 'rb') as f:
for line in f:
if 'CCC' in line:
break
if self.engine == 'c':
pytest.raises(Exception, self.read_table,
> f, squeeze=True, header=None)
E Failed: DID NOT RAISE <type 'exceptions.Exception'>
pandas/tests/io/parser/common.py:1309: Failed
______________________________________________ TestCParserLowMemory.test_iteration_open_handle ______________________________________________
self = <pandas.tests.io.parser.test_parsers.TestCParserLowMemory object at 0x000000000ff3dbe8>
def test_iteration_open_handle(self):
if PY3:
pytest.skip(
"won't work in Python 3 {0}".format(sys.version_info))
with tm.ensure_clean() as path:
with open(path, 'wb') as f:
f.write('AAA\nBBB\nCCC\nDDD\nEEE\nFFF\nGGG')
with open(path, 'rb') as f:
for line in f:
if 'CCC' in line:
break
if self.engine == 'c':
pytest.raises(Exception, self.read_table,
> f, squeeze=True, header=None)
E Failed: DID NOT RAISE <type 'exceptions.Exception'>
pandas/tests/io/parser/common.py:1309: Failed
_____________________________________________________ TestPythonParser.test_bad_quoting _____________________________________________________
self = <pandas.tests.io.parser.test_parsers.TestPythonParser object at 0x000000001055e6b0>
def test_bad_quoting(self):
data = '1,2,3'
msg = '"quoting" must be an integer'
tm.assert_raises_regex(TypeError, msg, self.read_csv,
> StringIO(data), quoting='foo')
pandas/tests/io/parser/quoting.py:40:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pandas/util/testing.py:2464: in assert_raises_regex
_callable(*args, **kwargs)
pandas/util/testing.py:2503: in __exit__
return self.exception_matches(exc_type, exc_value, trace_back)
pandas/util/testing.py:2539: in exception_matches
raise_with_traceback(e, trace_back)
pandas/util/testing.py:2464: in assert_raises_regex
_callable(*args, **kwargs)
pandas/tests/io/parser/test_parsers.py:97: in read_csv
return read_csv(*args, **kwds)
pandas/io/parsers.py:660: in parser_f
return _read(filepath_or_buffer, kwds)
pandas/io/parsers.py:410: in _read
parser = TextFileReader(filepath_or_buffer, **kwds)
pandas/io/parsers.py:769: in __init__
self._make_engine(self.engine)
pandas/io/parsers.py:1000: in _make_engine
self._engine = klass(self.f, **self.options)
pandas/io/parsers.py:2005: in __init__
self._make_reader(f)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pandas.io.parsers.PythonParser object at 0x000000001055f130>, f = <StringIO.StringIO instance at 0x00000000105425a0>
def _make_reader(self, f):
sep = self.delimiter
if sep is None or len(sep) == 1:
if self.lineterminator:
raise ValueError('Custom line terminators not supported in '
'python parser (yet)')
class MyDialect(csv.Dialect):
delimiter = self.delimiter
quotechar = self.quotechar
escapechar = self.escapechar
doublequote = self.doublequote
skipinitialspace = self.skipinitialspace
quoting = self.quoting
lineterminator = '\n'
dia = MyDialect
sniff_sep = True
if sep is not None:
sniff_sep = False
dia.delimiter = sep
# attempt to sniff the delimiter
if sniff_sep:
line = f.readline()
while self.skipfunc(self.pos):
self.pos += 1
line = f.readline()
line = self._check_comments([line])[0]
self.pos += 1
self.line_pos += 1
sniffed = csv.Sniffer().sniff(line)
dia.delimiter = sniffed.delimiter
if self.encoding is not None:
self.buf.extend(list(
UnicodeReader(StringIO(line),
dialect=dia,
encoding=self.encoding)))
else:
self.buf.extend(list(csv.reader(StringIO(line),
dialect=dia)))
if self.encoding is not None:
reader = UnicodeReader(f, dialect=dia,
encoding=self.encoding,
strict=True)
else:
reader = csv.reader(f, dialect=dia,
> strict=True)
E AssertionError: ""quoting" must be an integer" does not match "expected integer, got str object"
pandas/io/parsers.py:2143: AssertionError
________________________________________________________ TestInterval.test_math_mult ________________________________________________________
self = <pandas.tests.scalar.test_interval.TestInterval object at 0x000000000ae78560>, interval = Interval(0, 1, closed='right')
def test_math_mult(self, interval):
expected = Interval(0, 2)
actual = interval * 2
assert expected == actual
expected = Interval(0, 2)
actual = 2 * interval
assert expected == actual
actual = interval
actual *= 2
assert expected == actual
msg = "unsupported operand type\(s\) for \*"
with tm.assert_raises_regex(TypeError, msg):
interval * Interval(1, 2)
msg = "can\'t multiply sequence by non-int"
with tm.assert_raises_regex(TypeError, msg):
> interval * 'foo'
pandas/tests/scalar/test_interval.py:123:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pandas/util/testing.py:2503: in __exit__
return self.exception_matches(exc_type, exc_value, trace_back)
pandas/util/testing.py:2539: in exception_matches
raise_with_traceback(e, trace_back)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pandas.tests.scalar.test_interval.TestInterval object at 0x000000000ae78560>, interval = Interval(0, 1, closed='right')
def test_math_mult(self, interval):
expected = Interval(0, 2)
actual = interval * 2
assert expected == actual
expected = Interval(0, 2)
actual = 2 * interval
assert expected == actual
actual = interval
actual *= 2
assert expected == actual
msg = "unsupported operand type\(s\) for \*"
with tm.assert_raises_regex(TypeError, msg):
interval * Interval(1, 2)
msg = "can\'t multiply sequence by non-int"
with tm.assert_raises_regex(TypeError, msg):
> interval * 'foo'
E AssertionError: "can't multiply sequence by non-int" does not match "unsupported operand type(s) for *: 'Interval' and 'str'"
pandas/tests/scalar/test_interval.py:123: AssertionError
_____________________________________________________________ test_NaT_methods ______________________________________________________________
def test_NaT_methods():
# GH 9513
raise_methods = ['astimezone', 'combine', 'ctime', 'dst',
'fromordinal', 'fromtimestamp', 'isocalendar',
'strftime', 'strptime', 'time', 'timestamp',
'timetuple', 'timetz', 'toordinal', 'tzname',
'utcfromtimestamp', 'utcnow', 'utcoffset',
'utctimetuple']
nat_methods = ['date', 'now', 'replace', 'to_datetime', 'today',
'tz_convert', 'tz_localize']
nan_methods = ['weekday', 'isoweekday']
for method in raise_methods:
if hasattr(NaT, method):
with pytest.raises(ValueError):
getattr(NaT, method)()
for method in nan_methods:
if hasattr(NaT, method):
assert np.isnan(getattr(NaT, method)())
for method in nat_methods:
if hasattr(NaT, method):
# see gh-8254
exp_warning = None
if method == 'to_datetime':
exp_warning = FutureWarning
with tm.assert_produces_warning(
exp_warning, check_stacklevel=False):
> assert getattr(NaT, method)() is NaT
pandas/tests/scalar/test_nat.py:153:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> cpdef datetime to_datetime(_Timestamp self):
E ValueError: ('year must be in 1..9999', 0)
pandas/_libs/tslib.pyx:1150: ValueError
___________________________________________ TestMove.test_cannot_create_instance_of_stolenbuffer ____________________________________________
self = <pandas.tests.util.test_util.TestMove object at 0x00000000094034b0>
def test_cannot_create_instance_of_stolenbuffer(self):
"""Stolen buffers need to be created through the smart constructor
``move_into_mutable_buffer`` which has a bunch of checks in it.
"""
msg = "cannot create 'pandas.util._move.stolenbuf' instances"
with tm.assert_raises_regex(TypeError, msg):
> stolenbuf()
pandas/tests/util/test_util.py:330:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pandas.util.testing._AssertRaisesContextmanager object at 0x0000000009cab948>, exc_type = None, exc_value = None, trace_back = None
def __exit__(self, exc_type, exc_value, trace_back):
expected = self.exception
if not exc_type:
exp_name = getattr(expected, "__name__", str(expected))
> raise AssertionError("{name} not raised.".format(name=exp_name))
E AssertionError: TypeError not raised.
pandas/util/testing.py:2501: AssertionError
_______________________________________________________ TestMove.test_exactly_one_ref _______________________________________________________
self = <pandas.tests.util.test_util.TestMove object at 0x000000000cb663a0>
def test_exactly_one_ref(self):
"""Test case for when the object being moved has exactly one reference.
"""
b = b'testing'
# We need to pass an expression on the stack to ensure that there are
# not extra references hanging around. We cannot rewrite this test as
# buf = b[:-3]
# as_stolen_buf = move_into_mutable_buffer(buf)
# because then we would have more than one reference to buf.
> as_stolen_buf = move_into_mutable_buffer(b[:-3])
E BadMove: test
pandas/tests/util/test_util.py:356: BadMove
__________________________________________________________ TestMove.test_interned ___________________________________________________________
self = <pandas.tests.util.test_util.TestMove object at 0x000000000f814288>
@pytest.mark.skipif(
sys.version_info[0] > 2,
reason='bytes objects cannot be interned in py3',
)
def test_interned(self):
salt = uuid4().hex
def make_string():
# We need to actually create a new string so that it has refcount
# one. We use a uuid so that we know the string could not already
# be in the intern table.
return ''.join(('testing: ', salt))
# This should work, the string has one reference on the stack.
> move_into_mutable_buffer(make_string())
E BadMove: testing: 713d20a2ebac4e3aa49336f4d986e8ce
pandas/tests/util/test_util.py:375: BadMove
========================================================== 11664 tests deselected ===========================================================
================================ 13 failed, 6 passed, 13 skipped, 11664 deselected, 2 error in 40.07 seconds ================================
matti@asus:~/pypy_stuff/pandas$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment