8000 Merge pull request #5255 from juliantaylor/backports · numpy/numpy@a587b47 · GitHub
[go: up one dir, main page]

Skip to content

Commit a587b47

Browse files
committed
Merge pull request #5255 from juliantaylor/backports
1.9.1 Backports
2 parents 994e98c + 7d2ebea commit a587b47

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

doc/release/1.9.1-notes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ Issues fixed
1212
* gh-5100: restore object dtype inference from iterable objects without `len()`
1313
* gh-5163: avoid gcc-4.1.2 (red hat 5) miscompilation causing a crash
1414
* gh-5138: fix nanmedian on arrays containing inf
15+
* gh-5240: fix not returning out array from ufuncs with subok=False set
1516
* gh-5203: copy inherited masks in MaskedArray.__array_finalize__
1617
* gh-2317: genfromtxt did not handle filling_values=0 correctly
1718
* gh-5067: restore api of npy_PyFile_DupClose in python2
1819
* gh-5063: cannot convert invalid sequence index to tuple
1920
* gh-5082: Segmentation fault with argmin() on unicode arrays
2021
* gh-5095: don't propagate subtypes from np.where
2122
* gh-5104: np.inner segfaults with SciPy's sparse matrices
23+
* gh-5251: Issue with fromarrays not using correct format for unicode arrays
2224
* gh-5136: Import dummy_threading if importing threading fails
2325
* gh-5148: Make numpy import when run with Python flag '-OO'
2426
* gh-5147: Einsum double contraction in particular order causes ValueError

numpy/core/records.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@
7171
# are equally allowed
7272

7373
numfmt = nt.typeDict
74-
_typestr = nt._typestr
7574

7675
def find_duplicate(list):
7776
"""Find duplication in a list, return a list of duplicated elements"""
@@ -527,15 +526,12 @@ def fromarrays(arrayList, dtype=None, shape=None, formats=None,
527526
if formats is None and dtype is None:
528527
# go through each object in the list to see if it is an ndarray
529528
# and determine the formats.
530-
formats = ''
529+
formats = []
531530
for obj in arrayList:
532531
if not isinstance(obj, ndarray):
533532
raise ValueError("item in the array list must be an ndarray.")
534-
formats += _typestr[obj.dtype.type]
535-
if issubclass(obj.dtype.type, nt.flexible):
536-
formats += repr(obj.itemsize)
537-
formats += ','
538-
formats = formats[:-1]
533+
formats.append(obj.dtype.str)
534+
formats = ','.join(formats)
539535

540536
if dtype is not None:
541537
descr = sb.dtype(dtype)

numpy/core/tests/test_records.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import division, absolute_import, print_function
22

3+
import sys
34
from os import path
45
import numpy as np
56
from numpy.testing import *
@@ -15,6 +16,14 @@ def test_fromrecords(self):
1516
r = np.rec.fromrecords([[456, 'dbe', 1.2], [2, 'de', 1.3]],
1617
names='col1,col2,col3')
1718
assert_equal(r[0].item(), (456, 'dbe', 1.2))
19+
assert_equal(r['col1'].dtype.kind, 'i')
20+
if sys.version_info[0] >= 3:
21+
assert_equal(r['col2'].dtype.kind, 'U')
22+
assert_equal(r['col2'].dtype.itemsize, 12)
23+
else:
24+
assert_equal(r['col2'].dtype.kind, 'S')
25+
assert_equal(r['col2'].dtype.itemsize, 3)
26+
assert_equal(r['col3'].dtype.kind, 'f')
1827

1928
def test_method_array(self):
2029
r = np.rec.array(asbytes('abcdefg') * 100, formats='i2,a3,i4', shape=3, byteorder='big')

0 commit comments

Comments
 (0)
0