Repository: pandas-dev/pandas

Issue:
Error in test suite for timedelta operations
This is on the VM running pandas windows builds.
Windows XP
Python 2.7 32-bit
numpy 1.7.1

```
======================================================================
ERROR: test_timedelta_ops_with_missing_values (pandas.tseries.tests.test_timedeltas.TestTimedeltas)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\workspace\pandas-windows-test-py27\pandas\tseries\tests\test_timedeltas.py", line 247, in test_timedelta_ops_with_missing_values
    actual = s1 + timedelta_NaT
  File "C:\workspace\pandas-windows-test-py27\pandas\core\ops.py", line 461, in wrapper
    time_converted = _TimeOp.maybe_convert_for_time_op(left, right, name)
  File "C:\workspace\pandas-windows-test-py27\pandas\core\ops.py", line 428, in maybe_convert_for_time_op
    return cls(left, right, name)
  File "C:\workspace\pandas-windows-test-py27\pandas\core\ops.py", line 246, in __init__
    rvalues = self._convert_to_array(right, name=name, other=lvalues)
  File "C:\workspace\pandas-windows-test-py27\pandas\core\ops.py", line 363, in _convert_to_array
    " operation".format(pa.array(values).dtype))
TypeError: incompatible type [timedelta64[ns]] for a datetime/timedelta operation
```



Discussion:
@changhiskhan can I post / email how you setup this  vm - so I can replicate

i'll shoot you an email


Resolving patch:
diff --git a/pandas/core/panel.py b/pandas/core/panel.py
--- a/pandas/core/panel.py
+++ b/pandas/core/panel.py
@@ -537,7 +537,7 @@ def __setitem__(self, key, value):
             if value.shape != shape[1:]:
                 raise ValueError('shape of value must be {0}, shape of given '
                                  'object was {1}'.format(shape[1:],
-                                                         value.shape))
+                                                         tuple(map(int, value.shape))))
             mat = np.asarray(value)
         elif np.isscalar(value):
             dtype, value = _infer_dtype_from_scalar(value)


Test patch:
diff --git a/pandas/computation/tests/test_eval.py b/pandas/computation/tests/test_eval.py
--- a/pandas/computation/tests/test_eval.py
+++ b/pandas/computation/tests/test_eval.py
@@ -180,6 +180,11 @@ def test_floor_division(self):
             self.check_floor_division(lhs, '//', rhs)
 
     def test_pow(self):
+        import platform
+        if platform.system() == 'Windows':
+            raise nose.SkipTest('not testing pow on Windows')
+
+        # odd failure on win32 platform, so skip
         for lhs, rhs in product(self.lhses, self.rhses):
             self.check_pow(lhs, '**', rhs)
 
@@ -867,8 +872,13 @@ def testit(r_idx_type, c_idx_type, index_name):
                 expected = s + df
             assert_frame_equal(res, expected)
 
-        args = product(self.lhs_index_types, self.index_types,
-                       ('index', 'columns'))
+        # only test dt with dt, otherwise weird joins result
+        args = product(['i','u','s'],['i','u','s'],('index', 'columns'))
+        for r_idx_type, c_idx_type, index_name in args:
+            testit(r_idx_type, c_idx_type, index_name)
+
+        # dt with dt
+        args = product(['dt'],['dt'],('index', 'columns'))
         for r_idx_type, c_idx_type, index_name in args:
             testit(r_idx_type, c_idx_type, index_name)
 
diff --git a/pandas/tests/test_index.py b/pandas/tests/test_index.py
--- a/pandas/tests/test_index.py
+++ b/pandas/tests/test_index.py
@@ -20,6 +20,7 @@
 from pandas.util.testing import (assert_almost_equal, assertRaisesRegexp,
                                  assert_copy)
 from pandas import compat
+from pandas.compat import long
 
 import pandas.util.testing as tm
 import pandas.core.config as cf
@@ -1344,7 +1345,7 @@ def test_inplace_mutation_resets_values(self):
 
         # make sure label setting works too
         labels2 = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]
-        exp_values = np.array([(1, 'a')] * 6, dtype=object)
+        exp_values = np.array([(long(1), 'a')] * 6, dtype=object)
         new_values = mi2.set_labels(labels2).values
         # not inplace shouldn't change
         assert_almost_equal(mi2._tuples, vals2)
diff --git a/pandas/tests/test_indexing.py b/pandas/tests/test_indexing.py
--- a/pandas/tests/test_indexing.py
+++ b/pandas/tests/test_indexing.py
@@ -1687,7 +1687,7 @@ def test_detect_chained_assignment(self):
 
         # work with the chain
         expected = DataFrame([[-5,1],[-6,3]],columns=list('AB'))
-        df = DataFrame(np.arange(4).reshape(2,2),columns=list('AB'))
+        df = DataFrame(np.arange(4).reshape(2,2),columns=list('AB'),dtype='int64')
         self.assert_(not df._is_copy)
 
         df['A'][0] = -5
@@ -1695,7 +1695,7 @@ def test_detect_chained_assignment(self):
         assert_frame_equal(df, expected)
 
         expected = DataFrame([[-5,2],[np.nan,3.]],columns=list('AB'))
-        df = DataFrame({ 'A' : np.arange(2), 'B' : np.array(np.arange(2,4),dtype=np.float64)})
+        df = DataFrame({ 'A' : Series(range(2),dtype='int64'), 'B' : np.array(np.arange(2,4),dtype=np.float64)})
         self.assert_(not df._is_copy)
         df['A'][0] = -5
         df['A'][1] = np.nan
@@ -1703,7 +1703,7 @@ def test_detect_chained_assignment(self):
         self.assert_(not df['A']._is_copy)
 
         # using a copy (the chain), fails
-        df = DataFrame({ 'A' : np.arange(2), 'B' : np.array(np.arange(2,4),dtype=np.float64)})
+        df = DataFrame({ 'A' : Series(range(2),dtype='int64'), 'B' : np.array(np.arange(2,4),dtype=np.float64)})
         def f():
             df.loc[0]['A'] = -5
         self.assertRaises(com.SettingWithCopyError, f)
@@ -1711,7 +1711,7 @@ def f():
         # doc example
         df = DataFrame({'a' : ['one', 'one', 'two',
                                'three', 'two', 'one', 'six'],
-                        'c' : np.arange(7) })
+                        'c' : Series(range(7),dtype='int64') })
         self.assert_(not df._is_copy)
         expected = DataFrame({'a' : ['one', 'one', 'two',
                                      'three', 'two', 'one', 'six'],
diff --git a/pandas/util/testing.py b/pandas/util/testing.py
--- a/pandas/util/testing.py
+++ b/pandas/util/testing.py
@@ -177,8 +177,14 @@ def get_locales(prefix=None, normalize=True,
         For example::
 
             locale.setlocale(locale.LC_ALL, locale_string)
+
+    On error will return None (no locale available, e.g. Windows)
+
     """
-    raw_locales = locale_getter()
+    try:
+        raw_locales = locale_getter()
+    except:
+        return None
 
     try:
         raw_locales = str(raw_locales, encoding=pd.options.display.encoding)