Implemented a function for smarter debug formatting.#606
Implemented a function for smarter debug formatting.#606LukeMathWalker merged 31 commits intorust-ndarray:masterfrom andrei-papou:smart-debug-formatting
Conversation
src/arrayformat.rs
Outdated
|
|
||
| #[derive(Debug)] | ||
| enum ArrayDisplayMode { | ||
| // Array is small enough to me printed without omitting any values. |
|
The output looks quite nice! |
- fixed typo in ArrayDisplayMode comment - updated ArrayDisplayMode constructor to use shape instead of array - fixed output for complex dimensions
src/lib.rs
Outdated
| mod arrayformat; | ||
| mod data_traits; | ||
|
|
||
| pub use arrayformat::PRINT_ELEMENTS_LIMIT; |
There was a problem hiding this comment.
I'd refer to not reexport this public constant at the top level of the crate, but rather reexport it from some config or integration_test module.
As far as I can tell the motivation for making it pub is entirely for making it usable within the integration tests at tests/format.rs?
There was a problem hiding this comment.
Awesome. I think that's better. I understand your motivation to have a way of configuring formatting similar to numpy's set_printoptions, but we wouldn't be able to actually accomplish that through const PRINT_ELEMENT_LIMIT. I am actually not sure right now if that was possible at all for a user of the library to accomplish at compile time.
|
I personally don't like that the implementation detail |
|
@SuperFluffy I can move them to Although I agree that those tests should be unit tests, it would be good to give a user some control over |
|
@LukeMathWalker @SuperFluffy any more comments on the changes? I think all the previous issues are fixed |
|
Sorry for the late reply @andrei-papou, it has been a crazy week. |
|
I have opened a PR with some observations @andrei-papou. |
Smart debug formatting review
|
@LukeMathWalker I tried to make the function more modular by extracting parts of the functionality to other functions and by reducing the number of boolean flags. I also got rid of the explicit second for loop. I hope the code is a bit more readable now. Please take a look |
|
I have opened a PR on your branch, trying out a different approach to solve this issue @andrei-papou - let me know what you think of it. |
|
I am happy to merge this into master. Do you want to have a look @jturner314? |
|
@LukeMathWalker Sure, I'm happy to review it, but feel free to go ahead and merge it if it looks good to you. I won't be able to review it until late next week or so. (It's the end of the semester right now, so I'm busy with exams.) Thanks for working with @andrei-papou on this PR. |
|
I am happy to call the shots and go ahead with this one - I'd like to avoid consuming your time on PRs I am confident reviewing (we need it for all the others were I have little context 👀). |
|
Thank you. :) |
PR for #398
How it works:
The number of elements before ellipses is managed by the
PRINT_ELEMENTS_LIMITconstant.