summaryrefslogtreecommitdiff
path: root/numpy/lib
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2014-11-30 15:02:49 -0500
committerCharles Harris <charlesr.harris@gmail.com>2014-11-30 15:02:49 -0500
commit8a2dd0680e8470aab7ad63622c0d0af703f58d42 (patch)
tree0df08a2723df9d713229f9831adbd8d222242ae6 /numpy/lib
parentf7eb37f16d7abff1d11987dced498ce923088001 (diff)
parent1761a648f27cb1277897170ed220de9176d52a75 (diff)
downloadnumpy-8a2dd0680e8470aab7ad63622c0d0af703f58d42.tar.gz
Merge pull request #5327 from madawilliams/savetxt
ENH: More explicit error message for np.savetxt
Diffstat (limited to 'numpy/lib')
-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))