-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
TST: splitlines in rec2txt test #6423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TST: splitlines in rec2txt test #6423
Conversation
On windows the output has '\r\n' instead of '\n' for new lines.
attn @dopplershift I think this is an equivalent test . |
@JanSchulz Can you help out with the windows issue here? I do not have a system to test on and debugging via appveyor seems maddeningly painful! |
👍 from me. |
In windows this seems to output one windows = [' x y s s2', ' 1.000 2 foo bing ']
truth = [' x y s s2', ' 1.000 2 foo bing '] |
Sorry, had order flipped, windows adds an extra space. |
The division was always returning 1, use length of first element instead.
@dopplershift I think there was a bug in computing the width of the string columns which for some reason was behaving differently on windows/linux. |
I have a look... Looks like there are at least two problems: The one where the link step can't find png.lib and the one where there is a space difference. Re the png one: it seems that conda-forge recently added a libpng (and that one is installed), could be that there is a difference to the official one? https://github.com/conda-forge/libpng-feedstock/commits/master (cc: @ocefpaf) |
I think I have the space issue fixed |
# The division below handles unicode stored in array, which could | ||
# have 4 bytes per char | ||
length = max(len(colname), column.itemsize // column[0].itemsize) | ||
length = max(len(colname), len(column[0])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not convinced len()
will do what we want if the data for a column is ['foo', 'bars']
. Probably should change the test to have some differing string sizes and see what happens.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is that allowed in recarrays? The types look like fixed-width string, not variable width.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In [18]: a = np.array([(1, 'foo'), (2, 'bars')], dtype=np.dtype([('i', np.int32), ('s', np.str, 4)]))
In [19]: a
Out[19]:
array([(1, 'foo'), (2, 'bars')],
dtype=[('i', '<i4'), ('s', '<U4')])
In [20]: len(a['s'][0])
Out[20]: 3
I couldn't find a numpy function to get that 4 from the <U4
, which is what we really want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But it turns out my original code was broken as well:
In [29]: a['s'][0].itemsize
Out[29]: 3
WTF?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you want a.dtype['s'].itemsize
== 16 ( / 4 for Unicode == 4)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
len()
is not the right thing. The best I can come up with is int(a.dtype['s'].str[2:])
a48c04b
to
1900372
Compare
And tests are passing, but it is dying as while trying to build the conda package |
8577491
to
0cb2c3a
Compare
Fixed width byte/unicode dtypes seem to have the pattern "[|<>][US][1-9][0-9]*" thus if we drop the first two charters we will have the fixed width.
137f123
to
7765024
Compare
ok, this is now passing (except for a down-load error on one of the appveyor tests). I had to turn off the conda package building which is less than great, but makes the test useful again for code review. |
Is this going to be backported? matplotlib 1.5.2rc1 on Windows fails one test:
|
Yes, sorry this got lost in the appveyor related issues. On Sun, May 22, 2016, 20:12 Christoph Gohlke [email protected]
|
TST: splitlines in rec2txt test
backported to v1.5.x as cab8cf7 |
On windows the output has '\r\n' instead of '\n' for new
lines.
If this passes I plan to self-merge to un-break appveyor