Skip to content

Commit

Permalink
Fix tests that weren't run by PyCharm
Browse files Browse the repository at this point in the history
  • Loading branch information
nateyoder committed Dec 16, 2016
1 parent 23c133d commit 504c2a2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 17 deletions.
4 changes: 2 additions & 2 deletions pandas/tseries/tests/test_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import nose

import numpy as np
from pandas import Timestamp, Period
from pandas import Timestamp, Period, Index
from pandas.compat import u
import pandas.util.testing as tm
from pandas.tseries.offsets import Second, Milli, Micro
Expand Down Expand Up @@ -104,7 +104,7 @@ def test_dateindex_conversion(self):
for freq in ('B', 'L', 'S'):
dateindex = tm.makeDateIndex(k=10, freq=freq)
rs = self.dtc.convert(dateindex, None, None)
xp = converter.dates.date2num(dateindex._mpl_repr())
xp = Index(converter.dates.date2num(dateindex._mpl_repr()))
tm.assert_almost_equal(rs, xp, decimals)

def test_resolution(self):
Expand Down
15 changes: 6 additions & 9 deletions pandas/tseries/tests/test_period.py
Original file line number Diff line number Diff line change
Expand Up @@ -3521,8 +3521,8 @@ def test_map(self):
tm.assert_index_equal(result, expected)

result = index.map(lambda x: x.ordinal)
exp = np.array([x.ordinal for x in index], dtype=np.int64)
tm.assert_numpy_array_equal(result, exp)
exp = Index([x.ordinal for x in index])
tm.assert_index_equal(result, exp)

def test_map_with_string_constructor(self):
raw = [2005, 2007, 2009]
Expand All @@ -3534,20 +3534,17 @@ def test_map_with_string_constructor(self):
types += text_type,

for t in types:
expected = np.array(lmap(t, raw), dtype=object)
expected = Index(lmap(t, raw))
res = index.map(t)

# should return an array
tm.assertIsInstance(res, np.ndarray)
# should return an Index
tm.assertIsInstance(res, Index)

# preserve element types
self.assertTrue(all(isinstance(resi, t) for resi in res))

# dtype should be object
self.assertEqual(res.dtype, np.dtype('object').type)

# lastly, values should compare equal
tm.assert_numpy_array_equal(res, expected)
tm.assert_index_equal(res, expected)

def test_convert_array_of_periods(self):
rng = period_range('1/1/2000', periods=20, freq='D')
Expand Down
4 changes: 2 additions & 2 deletions pandas/tseries/tests/test_timedeltas.py
Original file line number Diff line number Diff line change
Expand Up @@ -1513,8 +1513,8 @@ def test_map(self):

f = lambda x: x.days
result = rng.map(f)
exp = np.array([f(x) for x in rng], dtype=np.int64)
self.assert_numpy_array_equal(result, exp)
exp = Int64Index([f(x) for x in rng])
self.assert_index_equal(result, exp)

def test_misc_coverage(self):

Expand Down
8 changes: 4 additions & 4 deletions pandas/tseries/tests/test_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -3003,8 +3003,8 @@ def test_map(self):

f = lambda x: x.strftime('%Y%m%d')
result = rng.map(f)
exp = np.array([f(x) for x in rng], dtype='=U8')
tm.assert_almost_equal(result, exp)
exp = Index([f(x) for x in rng], dtype='<U8')
tm.assert_index_equal(result, exp)

def test_iteration_preserves_tz(self):

Expand Down Expand Up @@ -3700,8 +3700,8 @@ def test_map_bug_1677(self):
f = index.asof

result = index.map(f)
expected = np.array([f(index[0])])
self.assert_numpy_array_equal(result, expected)
expected = Index([f(index[0])])
self.assert_index_equal(result, expected)

def test_groupby_function_tuple_1677(self):
df = DataFrame(np.random.rand(100),
Expand Down

0 comments on commit 504c2a2

Please sign in to comment.