Repository navigation
BUG: The last line of formatArray is not always wrapped correctly - #10172
Conversation
|
Some related things I still don't like: >>> np.set_printoptions(linewidth=18)
>>> np.full(8, fill_value=2) # last ) is past linewidth
array([2, 2, 2, 2,
2, 2, 2, 2])
>>> print str(np.full(18, fill_value=2)) # 2nd to last row has fewer elements
[2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2
2]Do you think this can be fixed by subtracting one from the requested linewidth everywhere but the last line, to account for the final |
There was a problem hiding this comment.
This line and a few others from the last PR are longer than 80 chars. Rename max_line_lento something shorter?
This is in my pipeline
Ugh I was just thinking about that when The rules need to be a bit more complex, because presumably we want As expected, this patch is not correct. |
|
Yeah locally I just tried this, and it fixes by peeves. Rename Then I also subtract 1 in the call to (feel free to choose better variable names! Also I think my computation of |
|
Hmm for the Edit: Never mind, I think subtracting 1 is sufficient since in the |
|
That's pretty similar to what I have locally, but keeping the 1.13 compatibility is hard. Perhaps for ease of correctness, I should just lift |
|
Yeah if you are being forced to add little legacy branches everywhere, at some point it is easier to just make a separate function for the legacy case, like you did for maskedarrays. |
35a17d6 to
90921ce
Compare
The old behaviour is kept under the legacy='1.13' flag, as usual See tests for the changes.
|
Actually wasn't too bad, I was misreading the failure - it was actually the non-legacy testcase, which did need an update |
90921ce to
e7f84cd
Compare
| def _extendLine(s, line, word, max_line_len, next_line_prefix): | ||
| if len((line + word).rstrip()) > max_line_len: | ||
| def _extendLine(s, line, word, line_width, next_line_prefix): | ||
| if len(line) + len(word) > line_width: |
There was a problem hiding this comment.
We're not passing the separator in any more, so trailing spaces are "real"
| [('1970-01-01T00:00:00',) ('1970-01-01T00:00:00',) ('1970-01-01T00:00:00',) | ||
| ('1970-01-01T00:00:00',) ('1970-01-01T00:00:00',) ( 'NaT',) | ||
| ( 'NaT',) ( 'NaT',) ( 'NaT',) | ||
| ( 'NaT',)]""") |
There was a problem hiding this comment.
This is only 74 characters, but if the last line had 2 more items, it would be 76, which would be too long. It's easier to play it safe, rather than being greedy and having to backtrack.
|
Looks good, I'm ready to merge if tests pass. We're saving the |
|
I've got two more changes I'd like to make:
Do you think we can work in parallel without these conflicting? Or shall I just shove them both into the next PR? |
If after 1.14.0 is released, it turns out we missed something, then I think that is what we should do for 1.14.1. |
I'm not sure what you mean by parallel, but I'm happy to do whatever is easiest for you. Add them as commits here, make them separate PRs, etc. |
|
Parallel as in you taking one of them. |
|
All right I'll try the suffix arg. I'll base on this PR. |
|
Wait.. what's the difference between suffix space, and simply reducing |
|
It means that |
|
(tests pass) |
|
All right, merging. |
The old behaviour is kept under the legacy='1.13' flag, as usual