summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_io.py
diff options
context:
space:
mode:
authorStefan van der Walt <stefan@sun.ac.za>2008-04-28 23:27:11 +0000
committerStefan van der Walt <stefan@sun.ac.za>2008-04-28 23:27:11 +0000
commite311e8d2d6e5f45184022ecba2f975c81caaca37 (patch)
tree9d0bd96f644521b041968759efd2ab65e1db346c /numpy/lib/tests/test_io.py
parente844ca27a66e34bede3e90b5591d28aa0ae1a0e2 (diff)
downloadnumpy-e311e8d2d6e5f45184022ecba2f975c81caaca37.tar.gz
Support for multi formatting elements in savetxt [patch by David Huard].
Closes #663.
Diffstat (limited to 'numpy/lib/tests/test_io.py')
-rw-r--r--numpy/lib/tests/test_io.py41
1 files changed, 20 insertions, 21 deletions
diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py
index 31eceb7f6..8e7ffc425 100644
--- a/numpy/lib/tests/test_io.py
+++ b/numpy/lib/tests/test_io.py
@@ -39,28 +39,27 @@ class TestSaveTxt(NumpyTestCase):
c.seek(0)
assert_equal(c.readlines(), ['1,2\n', '3,4\n'])
+ def test_format(self):
+ a = np.array([(1, 2), (3, 4)])
+ c = StringIO.StringIO()
+ # Sequence of formats
+ np.savetxt(c, a, fmt=['%02d', '%3.1f'])
+ c.seek(0)
+ assert_equal(c.readlines(), ['01 2.0\n', '03 4.0\n'])
-## def test_format(self):
-## a = np.array([(1, 2), (3, 4)])
-## c = StringIO.StringIO()
-## # Sequence of formats
-## np.savetxt(c, a, fmt=['%02d', '%3.1f'])
-## c.seek(0)
-## assert_equal(c.readlines(), ['01 2.0\n', '03 4.0\n'])
-##
-## # A single multiformat string
-## c = StringIO.StringIO()
-## np.savetxt(c, a, fmt='%02d : %3.1f')
-## c.seek(0)
-## lines = c.readlines()
-## assert_equal(lines, ['01 : 2.0\n', '03 : 4.0\n'])
-##
-## # Specify delimiter, should be overiden
-## c = StringIO.StringIO()
-## np.savetxt(c, a, fmt='%02d : %3.1f', delimiter=',')
-## c.seek(0)
-## lines = c.readlines()
-## assert_equal(lines, ['01 : 2.0\n', '03 : 4.0\n'])
+ # A single multiformat string
+ c = StringIO.StringIO()
+ np.savetxt(c, a, fmt='%02d : %3.1f')
+ c.seek(0)
+ lines = c.readlines()
+ assert_equal(lines, ['01 : 2.0\n', '03 : 4.0\n'])
+
+ # Specify delimiter, should be overiden
+ c = StringIO.StringIO()
+ np.savetxt(c, a, fmt='%02d : %3.1f', delimiter=',')
+ c.seek(0)
+ lines = c.readlines()
+ assert_equal(lines, ['01 : 2.0\n', '03 : 4.0\n'])
class TestLoadTxt(NumpyTestCase):