Skip to content

Commit

Permalink
Add a test, remove a printf statement.
Browse files Browse the repository at this point in the history
  • Loading branch information
WarrenWeckesser committed Mar 7, 2012
1 parent 62af55f commit 553382d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
24 changes: 24 additions & 0 deletions python/tests/test_readrows.py
Expand Up @@ -84,3 +84,27 @@ def test4():
else:
assert_array_equal(a, b)
os.remove(filename)

def test5():
text = """\
1.0-2.0j, 3+4j
5.0e-1, 6.0+0j
"""

f = open(filename, 'w')
f.write(text)
f.close()

dt = np.dtype([('x', np.complex128), ('y', np.complex128)])
a = np.array([(1.0-2.0j, 3.0+4.0j), (0.5, 6.0)], dtype=dt)
b = readrows(filename, dt, delimiter=',')

if np.__version__ == '1.4.1':
# XXX Test fixed for 1.4.1. I haven't tracked down why assert_array_equal
# fails in 1.4.1. I also haven't tried it with 1.5.1.
assert_equal(a.shape, b.shape)
for arow, brow in zip(a,b):
assert_array_equal(arow, brow)
else:
assert_array_equal(a, b)
os.remove(filename)
1 change: 0 additions & 1 deletion src/rows.c
Expand Up @@ -323,7 +323,6 @@ void *read_rows(FILE *f, int *nrows, char *fmt,
else if (typ == 'c' || typ == 'z') {
// Convert to complex.
double x, y;
printf("... '%s' size=%d\n", result[k], ftypes[j].size);
if ((strlen(result[k]) == 0) || !to_complex(result[k], &x, &y, sci, decimal)) {
// XXX Find the canonical platform-independent method to assign nan.
x = 0.0 / 0.0;
Expand Down

0 comments on commit 553382d

Please sign in to comment.