Skip to content

Commit 751164d

Browse files
committed
Merge pull request #10630 from jreback/winbuild
TST: windows compat for testing / msgpack
2 parents c62cf68 + 022d7c5 commit 751164d

File tree

12 files changed

+102
-13
lines changed

12 files changed

+102
-13
lines changed

doc/source/whatsnew/v0.17.0.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ Bug Fixes
370370
- Bug in ``DatetimeIndex`` and ``PeriodIndex.value_counts`` resets name from its result, but retains in result's ``Index``. (:issue:`10150`)
371371
- Bug in `pd.eval` using ``numexpr`` engine coerces 1 element numpy array to scalar (:issue:`10546`)
372372
- Bug in `pandas.concat` with ``axis=0`` when column is of dtype ``category`` (:issue:`10177`)
373-
- Bug in ``read_msgpack`` where input type is not always checked (:issue:`10369`)
373+
- Bug in ``read_msgpack`` where input type is not always checked (:issue:`10369`, :issue:`10630`)
374374
- Bug in `pandas.read_csv` with kwargs ``index_col=False``, ``index_col=['a', 'b']`` or ``dtype``
375375
(:issue:`10413`, :issue:`10467`, :issue:`10577`)
376376
- Bug in `Series.from_csv` with ``header`` kwarg not setting the ``Series.name`` or the ``Series.index.name`` (:issue:`10483`)

pandas/io/packers.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,16 @@ def read(fh):
169169
u('datetime64[us]'): np.dtype('M8[us]'),
170170
22: np.dtype('m8[ns]'),
171171
u('timedelta64[ns]'): np.dtype('m8[ns]'),
172-
u('timedelta64[us]'): np.dtype('m8[us]')}
172+
u('timedelta64[us]'): np.dtype('m8[us]'),
173+
174+
# this is platform int, which we need to remap to np.int64
175+
# for compat on windows platforms
176+
7: np.dtype('int64'),
177+
}
173178

174179

175180
def dtype_for(t):
181+
""" return my dtype mapping, whether number or name """
176182
if t in dtype_dict:
177183
return dtype_dict[t]
178184
return np.typeDict[t]
@@ -266,7 +272,7 @@ def encode(obj):
266272
'klass': obj.__class__.__name__,
267273
'name': getattr(obj, 'name', None),
268274
'freq': getattr(obj, 'freqstr', None),
269-
'dtype': obj.dtype.num,
275+
'dtype': obj.dtype.name,
270276
'data': convert(obj.asi8),
271277
'compress': compressor}
272278
elif isinstance(obj, DatetimeIndex):
@@ -279,7 +285,7 @@ def encode(obj):
279285
return {'typ': 'datetime_index',
280286
'klass': obj.__class__.__name__,
281287
'name': getattr(obj, 'name', None),
282-
'dtype': obj.dtype.num,
288+
'dtype': obj.dtype.name,
283289
'data': convert(obj.asi8),
284290
'freq': getattr(obj, 'freqstr', None),
285291
'tz': tz,
@@ -288,14 +294,14 @@ def encode(obj):
288294
return {'typ': 'multi_index',
289295
'klass': obj.__class__.__name__,
290296
'names': getattr(obj, 'names', None),
291-
'dtype': obj.dtype.num,
297+
'dtype': obj.dtype.name,
292298
'data': convert(obj.values),
293299
'compress': compressor}
294300
else:
295301
return {'typ': 'index',
296302
'klass': obj.__class__.__name__,
297303
'name': getattr(obj, 'name', None),
298-
'dtype': obj.dtype.num,
304+
'dtype': obj.dtype.name,
299305
'data': convert(obj.values),
300306
'compress': compressor}
301307
elif isinstance(obj, Series):
@@ -305,7 +311,7 @@ def encode(obj):
305311
)
306312
#d = {'typ': 'sparse_series',
307313
# 'klass': obj.__class__.__name__,
308-
# 'dtype': obj.dtype.num,
314+
# 'dtype': obj.dtype.name,
309315
# 'index': obj.index,
310316
# 'sp_index': obj.sp_index,
311317
# 'sp_values': convert(obj.sp_values),
@@ -318,7 +324,7 @@ def encode(obj):
318324
'klass': obj.__class__.__name__,
319325
'name': getattr(obj, 'name', None),
320326
'index': obj.index,
321-
'dtype': obj.dtype.num,
327+
'dtype': obj.dtype.name,
322328
'data': convert(obj.values),
323329
'compress': compressor}
324330
elif issubclass(tobj, NDFrame):
@@ -360,7 +366,7 @@ def encode(obj):
360366
'locs': b.mgr_locs.as_array,
361367
'values': convert(b.values),
362368
'shape': b.values.shape,
363-
'dtype': b.dtype.num,
369+
'dtype': b.dtype.name,
364370
'klass': b.__class__.__name__,
365371
'compress': compressor
366372
} for b in data.blocks]}
@@ -413,7 +419,7 @@ def encode(obj):
413419
return {'typ': 'ndarray',
414420
'shape': obj.shape,
415421
'ndim': obj.ndim,
416-
'dtype': obj.dtype.num,
422+
'dtype': obj.dtype.name,
417423
'data': convert(obj),
418424
'compress': compressor}
419425
elif isinstance(obj, np.number):
@@ -449,11 +455,12 @@ def decode(obj):
449455
return Period(ordinal=obj['ordinal'], freq=obj['freq'])
450456
elif typ == 'index':
451457
dtype = dtype_for(obj['dtype'])
452-
data = unconvert(obj['data'], np.typeDict[obj['dtype']],
458+
data = unconvert(obj['data'], dtype,
453459
obj.get('compress'))
454460
return globals()[obj['klass']](data, dtype=dtype, name=obj['name'])
455461
elif typ == 'multi_index':
456-
data = unconvert(obj['data'], np.typeDict[obj['dtype']],
462+
dtype = dtype_for(obj['dtype'])
463+
data = unconvert(obj['data'], dtype,
457464
obj.get('compress'))
458465
data = [tuple(x) for x in data]
459466
return globals()[obj['klass']].from_tuples(data, names=obj['names'])
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

pandas/io/tests/test_cparser.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,30 @@ def test_header_not_enough_lines(self):
186186
'1,2,3\n'
187187
'4,5,6')
188188

189+
reader = TextReader(StringIO(data), delimiter=',', header=2)
190+
header = reader.header
191+
expected = [['a', 'b', 'c']]
192+
self.assertEqual(header, expected)
193+
194+
recs = reader.read()
195+
expected = {0 : [1, 4], 1 : [2, 5], 2 : [3, 6]}
196+
assert_array_dicts_equal(expected, recs)
197+
198+
# not enough rows
199+
self.assertRaises(parser.CParserError, TextReader, StringIO(data),
200+
delimiter=',', header=5, as_recarray=True)
201+
202+
def test_header_not_enough_lines_as_recarray(self):
203+
204+
if compat.is_platform_windows():
205+
raise nose.SkipTest("segfaults on win-64, only when all tests are run")
206+
207+
data = ('skip this\n'
208+
'skip this\n'
209+
'a,b,c\n'
210+
'1,2,3\n'
211+
'4,5,6')
212+
189213
reader = TextReader(StringIO(data), delimiter=',', header=2,
190214
as_recarray=True)
191215
header = reader.header
@@ -246,6 +270,21 @@ def _make_reader(**kwds):
246270
self.assertTrue((result[0] == ex_values).all())
247271
self.assertEqual(result[1].dtype, 'S4')
248272

273+
def test_numpy_string_dtype_as_recarray(self):
274+
data = """\
275+
a,1
276+
aa,2
277+
aaa,3
278+
aaaa,4
279+
aaaaa,5"""
280+
281+
if compat.is_platform_windows():
282+
raise nose.SkipTest("segfaults on win-64, only when all tests are run")
283+
284+
def _make_reader(**kwds):
285+
return TextReader(StringIO(data), delimiter=',', header=None,
286+
**kwds)
287+
249288
reader = _make_reader(dtype='S4', as_recarray=True)
250289
result = reader.read()
251290
self.assertEqual(result['0'].dtype, 'S4')

pandas/io/tests/test_json/test_ujson.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ def test_decimalDecodeTestPrecise(self):
114114
self.assertEqual(sut, decoded)
115115

116116
def test_encodeDoubleTinyExponential(self):
117+
if compat.is_platform_windows() and not compat.PY3:
118+
raise nose.SkipTest("buggy on win-64 for py2")
119+
117120
num = 1e-40
118121
self.assertEqual(num, ujson.decode(ujson.encode(num)))
119122
num = 1e-100

0 commit comments

Comments
 (0)