Skip to content

TST/CLN: centralize numpy < 1.7 skips #7696

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
Jul 8, 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
5 changes: 2 additions & 3 deletions pandas/io/tests/test_json/test_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import numpy as np
import nose
from pandas import Series, DataFrame, DatetimeIndex, Timestamp, _np_version_under1p7
from pandas import Series, DataFrame, DatetimeIndex, Timestamp
import pandas as pd
read_json = pd.read_json

Expand Down Expand Up @@ -601,8 +601,7 @@ def test_url(self):
self.assertEqual(result[c].dtype, 'datetime64[ns]')

def test_timedelta(self):
if _np_version_under1p7:
raise nose.SkipTest("numpy < 1.7")
tm._skip_if_not_numpy17_friendly()

from datetime import timedelta
converter = lambda x: pd.to_timedelta(x,unit='ms')
Expand Down
9 changes: 2 additions & 7 deletions pandas/io/tests/test_pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -2061,11 +2061,7 @@ def compare(a,b):
def test_append_with_timezones_dateutil(self):

from datetime import timedelta

try:
import dateutil
except ImportError:
raise nose.SkipTest
tm._skip_if_no_dateutil()

# use maybe_get_tz instead of dateutil.tz.gettz to handle the windows filename issues.
from pandas.tslib import maybe_get_tz
Expand Down Expand Up @@ -2186,8 +2182,7 @@ def setTZ(tz):
setTZ(orig_tz)

def test_append_with_timedelta(self):
if _np_version_under1p7:
raise nose.SkipTest("requires numpy >= 1.7")
tm._skip_if_not_numpy17_friendly()

# GH 3577
# append timedelta
Expand Down
5 changes: 2 additions & 3 deletions pandas/io/tests/test_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,7 @@ def test_date_and_index(self):

def test_timedelta(self):
# see #6921
if _np_version_under1p7:
raise nose.SkipTest("test only valid in numpy >= 1.7")
tm._skip_if_not_numpy17_friendly()

df = to_timedelta(Series(['00:00:01', '00:00:03'], name='foo')).to_frame()
with tm.assert_produces_warning(UserWarning):
Expand Down Expand Up @@ -659,7 +658,7 @@ def test_not_reflect_all_tables(self):
self.conn.execute(qry)
qry = """CREATE TABLE other_table (x INTEGER, y INTEGER);"""
self.conn.execute(qry)

with warnings.catch_warnings(record=True) as w:
# Cause all warnings to always be triggered.
warnings.simplefilter("always")
Expand Down
3 changes: 1 addition & 2 deletions pandas/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,7 @@ def setUp(self):
self.not_valid_objs = [ o for o in self.objs if not o._allow_index_ops ]

def test_ops(self):
if _np_version_under1p7:
raise nose.SkipTest("test only valid in numpy >= 1.7")
tm._skip_if_not_numpy17_friendly()
for op in ['max','min']:
for o in self.objs:
result = getattr(o,op)()
Expand Down
11 changes: 2 additions & 9 deletions pandas/tests/test_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,6 @@ def has_expanded_repr(df):
return True
return False

def skip_if_np_version_under1p7():
if _np_version_under1p7:
import nose

raise nose.SkipTest('numpy >= 1.7 required')


class TestDataFrameFormatting(tm.TestCase):
_multiprocess_can_split_ = True

Expand Down Expand Up @@ -2736,7 +2729,7 @@ def test_format(self):
class TestRepr_timedelta64(tm.TestCase):
@classmethod
def setUpClass(cls):
skip_if_np_version_under1p7()
tm._skip_if_not_numpy17_friendly()

def test_legacy(self):
delta_1d = pd.to_timedelta(1, unit='D')
Expand Down Expand Up @@ -2784,7 +2777,7 @@ def test_long(self):
class TestTimedelta64Formatter(tm.TestCase):
@classmethod
def setUpClass(cls):
skip_if_np_version_under1p7()
tm._skip_if_not_numpy17_friendly()

def test_mixed(self):
x = pd.to_timedelta(list(range(5)) + [pd.NaT], unit='D')
Expand Down
7 changes: 3 additions & 4 deletions pandas/tests/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
import pandas.core.format as fmt
import pandas.core.datetools as datetools
from pandas import (DataFrame, Index, Series, notnull, isnull,
MultiIndex, DatetimeIndex, Timestamp, date_range, read_csv,
_np_version_under1p7)
MultiIndex, DatetimeIndex, Timestamp, date_range, read_csv)
import pandas as pd
from pandas.parser import CParserError
from pandas.util.misc import is_little_endian
Expand Down Expand Up @@ -3772,8 +3771,7 @@ def test_operators_timedelta64(self):
self.assertTrue(df['off2'].dtype == 'timedelta64[ns]')

def test_datetimelike_setitem_with_inference(self):
if _np_version_under1p7:
raise nose.SkipTest("numpy < 1.7")
tm._skip_if_not_numpy17_friendly()

# GH 7592
# assignment of timedeltas with NaT
Expand Down Expand Up @@ -13036,6 +13034,7 @@ def test_select_dtypes_exclude_include(self):
tm.assert_frame_equal(r, e)

def test_select_dtypes_not_an_attr_but_still_valid_dtype(self):
tm._skip_if_not_numpy17_friendly()
df = DataFrame({'a': list('abc'),
'b': list(range(1, 4)),
'c': np.arange(3, 6).astype('u1'),
Expand Down
5 changes: 2 additions & 3 deletions pandas/tests/test_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import pandas as pd

from pandas import (Index, Series, DataFrame, Panel,
isnull, notnull,date_range, _np_version_under1p7)
isnull, notnull,date_range)
from pandas.core.index import Index, MultiIndex

import pandas.core.common as com
Expand Down Expand Up @@ -160,8 +160,7 @@ def f():
self.assertRaises(ValueError, lambda : not obj1)

def test_numpy_1_7_compat_numeric_methods(self):
if _np_version_under1p7:
raise nose.SkipTest("numpy < 1.7")
tm._skip_if_not_numpy17_friendly()

# GH 4435
# numpy in 1.7 tries to pass addtional arguments to pandas functions
Expand Down
7 changes: 1 addition & 6 deletions pandas/tests/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@

from pandas import _np_version_under1p7

def _skip_if_need_numpy_1_7():
if _np_version_under1p7:
raise nose.SkipTest('numpy >= 1.7 required')


class TestIndex(tm.TestCase):
_multiprocess_can_split_ = True

Expand Down Expand Up @@ -340,7 +335,7 @@ def test_asof(self):
tm.assert_isinstance(self.dateIndex.asof(d), Timestamp)

def test_nanosecond_index_access(self):
_skip_if_need_numpy_1_7()
tm._skip_if_not_numpy17_friendly()

s = Series([Timestamp('20130101')]).values.view('i8')[0]
r = DatetimeIndex([s + 50 + i for i in range(100)])
Expand Down
12 changes: 4 additions & 8 deletions pandas/tests/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -2721,8 +2721,7 @@ def test_timedelta64_operations_with_integers(self):
self.assertRaises(TypeError, sop, s2.values)

def test_timedelta64_conversions(self):
if _np_version_under1p7:
raise nose.SkipTest("cannot use 2 argument form of timedelta64 conversions with numpy < 1.7")
tm._skip_if_not_numpy17_friendly()

startdate = Series(date_range('2013-01-01', '2013-01-03'))
enddate = Series(date_range('2013-03-01', '2013-03-03'))
Expand Down Expand Up @@ -2835,8 +2834,7 @@ def run_ops(ops, get_ser, test_ser):
dt1 + td1

def test_ops_datetimelike_align(self):
if _np_version_under1p7:
raise nose.SkipTest("timedelta broken in np < 1.7")
tm._skip_if_not_numpy17_friendly()

# GH 7500
# datetimelike ops need to align
Expand Down Expand Up @@ -2899,8 +2897,7 @@ def test_timedelta64_functions(self):
assert_series_equal(result, expected)

def test_timedelta_fillna(self):
if _np_version_under1p7:
raise nose.SkipTest("timedelta broken in np 1.6.1")
tm._skip_if_not_numpy17_friendly()

#GH 3371
s = Series([Timestamp('20130101'), Timestamp('20130101'),
Expand Down Expand Up @@ -3107,8 +3104,7 @@ def test_bfill(self):
assert_series_equal(ts.bfill(), ts.fillna(method='bfill'))

def test_sub_of_datetime_from_TimeSeries(self):
if _np_version_under1p7:
raise nose.SkipTest("timedelta broken in np 1.6.1")
tm._skip_if_not_numpy17_friendly()

from pandas.tseries.timedeltas import _possibly_cast_to_timedelta
from datetime import datetime
Expand Down
7 changes: 2 additions & 5 deletions pandas/tools/tests/test_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -812,8 +812,7 @@ def test_join_append_timedeltas(self):

# timedelta64 issues with join/merge
# GH 5695
if _np_version_under1p7:
raise nose.SkipTest("numpy < 1.7")
tm._skip_if_not_numpy17_friendly()

d = {'d': dt.datetime(2013, 11, 5, 5, 56), 't': dt.timedelta(0, 22500)}
df = DataFrame(columns=list('dt'))
Expand Down Expand Up @@ -2005,9 +2004,7 @@ def test_concat_datetime64_block(self):
def test_concat_timedelta64_block(self):

# not friendly for < 1.7
if _np_version_under1p7:
raise nose.SkipTest("numpy < 1.7")

tm._skip_if_not_numpy17_friendly()
from pandas import to_timedelta

rng = to_timedelta(np.arange(10),unit='s')
Expand Down
3 changes: 1 addition & 2 deletions pandas/tseries/tests/test_frequencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@ def test_microsecond(self):
self._check_tick(timedelta(microseconds=1), 'U')

def test_nanosecond(self):
if _np_version_under1p7:
raise nose.SkipTest("requires numpy >= 1.7 to run")
tm._skip_if_not_numpy17_friendly()
self._check_tick(np.timedelta64(1, 'ns'), 'N')

def _check_tick(self, base_delta, code):
Expand Down
9 changes: 4 additions & 5 deletions pandas/tseries/tests/test_offsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def setUp(self):
'Milli': Timestamp('2011-01-01 09:00:00.001000'),
'Micro': Timestamp('2011-01-01 09:00:00.000001'),
'Nano': Timestamp(np.datetime64('2011-01-01T09:00:00.000000001Z'))}

self.timezones = ['UTC', 'Asia/Tokyo', 'US/Eastern']

def test_return_type(self):
Expand Down Expand Up @@ -2782,8 +2782,8 @@ def test_Microsecond():


def test_NanosecondGeneric():
if _np_version_under1p7:
raise nose.SkipTest('numpy >= 1.7 required')
tm._skip_if_not_numpy17_friendly()

timestamp = Timestamp(datetime(2010, 1, 1))
assert timestamp.nanosecond == 0

Expand All @@ -2795,8 +2795,7 @@ def test_NanosecondGeneric():


def test_Nanosecond():
if _np_version_under1p7:
raise nose.SkipTest('numpy >= 1.7 required')
tm._skip_if_not_numpy17_friendly()

timestamp = Timestamp(datetime(2010, 1, 1))
assertEq(Nano(), timestamp, timestamp + np.timedelta64(1, 'ns'))
Expand Down
Loading