summaryrefslogtreecommitdiff
path: root/numpy/core/records.py
diff options
context:
space:
mode:
authorMike Taves <mwtoews@gmail.com>2021-08-30 11:01:34 +1200
committerMike Taves <mwtoews@gmail.com>2021-09-01 21:50:59 +1200
commit64f15a94708095bf9d29af5dbfcc4b654a57248a (patch)
tree77bd3bf8a4f38561fee95fcfa3ea9e5247e6500b /numpy/core/records.py
parent5ae53e93b2be9ccf47bf72a85d71ea15d15a2eed (diff)
downloadnumpy-64f15a94708095bf9d29af5dbfcc4b654a57248a.tar.gz
MAINT: refactor "for ... in range(len(" statements
Diffstat (limited to 'numpy/core/records.py')
-rw-r--r--numpy/core/records.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/numpy/core/records.py b/numpy/core/records.py
index b3474ad01..2c20b7d45 100644
--- a/numpy/core/records.py
+++ b/numpy/core/records.py
@@ -664,17 +664,17 @@ def fromarrays(arrayList, dtype=None, shape=None, formats=None,
if nn > 0:
shape = shape[:-nn]
+ _array = recarray(shape, descr)
+
+ # populate the record array (makes a copy)
for k, obj in enumerate(arrayList):
nn = descr[k].ndim
testshape = obj.shape[:obj.ndim - nn]
+ name = _names[k]
if testshape != shape:
- raise ValueError("array-shape mismatch in array %d" % k)
+ raise ValueError(f'array-shape mismatch in array {k} ("{name}")')
- _array = recarray(shape, descr)
-
- # populate the record array (makes a copy)
- for i in range(len(arrayList)):
- _array[_names[i]] = arrayList[i]
+ _array[name] = obj
return _array