Skip to content

TST: test fixes for various builds (debian) #3898

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 6 commits into from
Jun 14, 2013
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
19 changes: 19 additions & 0 deletions pandas/io/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,15 @@ def _try_convert_data(self, name, data, use_dtypes=True, convert_dates=True):
except:
pass

if data.dtype == 'float':

# coerce floats to 64
try:
data = data.astype('float64')
result = True
except:
pass

# do't coerce 0-len data
if len(data) and (data.dtype == 'float' or data.dtype == 'object'):

Expand All @@ -280,6 +289,16 @@ def _try_convert_data(self, name, data, use_dtypes=True, convert_dates=True):
except:
pass

# coerce ints to 64
if data.dtype == 'int':

# coerce floats to 64
try:
data = data.astype('int64')
result = True
except:
pass

return data, result

def _try_convert_to_date(self, data):
Expand Down
6 changes: 1 addition & 5 deletions pandas/io/tests/test_excel.py
Original file line number Diff line number Diff line change
Expand Up @@ -808,11 +808,7 @@ def test_to_excel_styleconverter(self):
# self.assertTrue(ws.cell(maddr).merged)
# os.remove(filename)
def test_excel_010_hemstring(self):
try:
import xlwt
import openpyxl
except ImportError:
raise nose.SkipTest
_skip_if_no_excelsuite()

from pandas.util.testing import makeCustomDataframe as mkdf
# ensure limited functionality in 0.10
Expand Down
7 changes: 5 additions & 2 deletions pandas/io/tests/test_json/test_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

_frame = DataFrame(_seriesd)
_frame2 = DataFrame(_seriesd, columns=['D', 'C', 'B', 'A'])
_intframe = DataFrame(dict((k, v.astype(int))
_intframe = DataFrame(dict((k, v.astype(np.int64))
for k, v in _seriesd.iteritems()))

_tsframe = DataFrame(_tsd)
Expand Down Expand Up @@ -71,6 +71,9 @@ def _check_orient(df, orient, dtype=None, numpy=False, convert_axes=True, check_

unser = unser.sort()

if dtype is False:
check_dtype=False

if not convert_axes and df.index.dtype.type == np.datetime64:
unser.index = DatetimeIndex(unser.index.values.astype('i8'))
if orient == "records":
Expand Down Expand Up @@ -288,7 +291,7 @@ def test_series_to_json_except(self):

def test_typ(self):

s = Series(range(6), index=['a','b','c','d','e','f'])
s = Series(range(6), index=['a','b','c','d','e','f'], dtype='int64')
result = read_json(s.to_json(),typ=None)
assert_series_equal(result,s)

Expand Down
4 changes: 4 additions & 0 deletions pandas/io/tests/test_pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
from pandas import Index
from pandas.sparse.tests import test_sparse
from pandas.util import py3compat
from pandas.util.decorators import knownfailureif
from pandas.util.misc import is_little_endian

class TestPickle(unittest.TestCase):
_multiprocess_can_split_ = True
Expand Down Expand Up @@ -56,13 +58,15 @@ def compare(self, vf):
comparator = getattr(tm,"assert_%s_equal" % typ)
comparator(result,expected)

@knownfailureif(not is_little_endian(), "known failure of test_read_pickles_0_10_1 on non-little endian")
def test_read_pickles_0_10_1(self):

pth = tm.get_data_path('legacy_pickle/0.10.1')
for f in os.listdir(pth):
vf = os.path.join(pth,f)
self.compare(vf)

@knownfailureif(not is_little_endian(), "known failure of test_read_pickles_0_11_0 on non-little endian")
def test_read_pickles_0_11_0(self):

pth = tm.get_data_path('legacy_pickle/0.11.0')
Expand Down
3 changes: 3 additions & 0 deletions pandas/io/tests/test_pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,9 @@ def test_append(self):

def test_encoding(self):

if sys.byteorder != 'little':
raise nose.SkipTest('system byteorder is not little, skipping test_encoding!')

with ensure_clean(self.path) as store:
df = DataFrame(dict(A='foo',B='bar'),index=range(5))
df.loc[2,'A'] = np.nan
Expand Down
6 changes: 5 additions & 1 deletion pandas/io/tests/test_stata.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from datetime import datetime
import os
import unittest

import sys
import warnings
import nose

Expand All @@ -14,6 +14,8 @@
from pandas.io.stata import read_stata, StataReader, StataWriter
import pandas.util.testing as tm
from pandas.util.testing import ensure_clean
from pandas.util.decorators import knownfailureif
from pandas.util.misc import is_little_endian

class StataTests(unittest.TestCase):

Expand Down Expand Up @@ -127,6 +129,7 @@ def test_read_dta4(self):

tm.assert_frame_equal(parsed, expected)

@knownfailureif(not is_little_endian(), "known failure of test_write_dta5 on non-little endian")
def test_write_dta5(self):
original = DataFrame([(np.nan, np.nan, np.nan, np.nan, np.nan)],
columns=['float_miss', 'double_miss', 'byte_miss', 'int_miss', 'long_miss'])
Expand All @@ -137,6 +140,7 @@ def test_write_dta5(self):
written_and_read_again = self.read_dta(path)
tm.assert_frame_equal(written_and_read_again.set_index('index'), original)

@knownfailureif(not is_little_endian(), "known failure of test_write_dta6 on non-little endian")
def test_write_dta6(self):
original = self.read_csv(self.csv3)
original.index.name = 'index'
Expand Down
6 changes: 5 additions & 1 deletion pandas/tests/test_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -1381,7 +1381,11 @@ def test_to_excel(self):
path = '__tmp__.' + ext
with ensure_clean(path) as path:
self.panel.to_excel(path)
reader = ExcelFile(path)
try:
reader = ExcelFile(path)
except ImportError:
raise nose.SkipTest

for item, df in self.panel.iterkv():
recdf = reader.parse(str(item), index_col=0)
assert_frame_equal(df, recdf)
Expand Down
7 changes: 7 additions & 0 deletions pandas/util/misc.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
""" various miscellaneous utilities """

def is_little_endian():
""" am I little endian """
import sys
return sys.byteorder == 'little'

def exclusive(*args):
count = sum([arg is not None for arg in args])
return count == 1