summaryrefslogtreecommitdiff
path: root/numpy/lib/npyio.py
diff options
context:
space:
mode:
authorAdam Williams <madawilliams@gmail.com>2014-11-30 15:51:51 +0000
committerAdam Williams <madawilliams@gmail.com>2014-11-30 15:51:51 +0000
commit1761a648f27cb1277897170ed220de9176d52a75 (patch)
treeb50df86c7cc40eb9070878208a3992e632e5f3f0 /numpy/lib/npyio.py
parent0afa5fc05032cacae38280063544ca5d315d6d1d (diff)
downloadnumpy-1761a648f27cb1277897170ed220de9176d52a75.tar.gz
ENH: More explicit error message for np.savetxt
Diffstat (limited to 'numpy/lib/npyio.py')
-rw-r--r--numpy/lib/npyio.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py
index cbef1a6e2..e7287ea8f 100644
--- a/numpy/lib/npyio.py
+++ b/numpy/lib/npyio.py
@@ -1088,7 +1088,12 @@ def savetxt(fname, X, fmt='%.18e', delimiter=' ', newline='\n', header='',
fh.write(asbytes(format % tuple(row2) + newline))
else:
for row in X:
- fh.write(asbytes(format % tuple(row) + newline))
+ try:
+ fh.write(asbytes(format % tuple(row) + newline))
+ except TypeError:
+ raise TypeError("Mismatch between array dtype ('%s') and "
+ "format specifier ('%s')"
+ % (str(X.dtype), format))
if len(footer) > 0:
footer = footer.replace('\n', '\n' + comments)
fh.write(asbytes(comments + footer + newline))