-
Notifications
You must be signed in to change notification settings - Fork 308
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
Implemented a function for smarter debug formatting. #606
Implemented a function for smarter debug formatting. #606
Conversation
src/arrayformat.rs
Outdated
}; | ||
use crate::dimension::IntoDimension; | ||
|
||
#[derive(Debug)] | ||
enum ArrayDisplayMode { | ||
// Array is small enough to me printed without omitting any values. |
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.
Typo: to me printed
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
@@ -149,6 +149,8 @@ mod array_serde; | |||
mod arrayformat; | |||
mod data_traits; | |||
|
|||
pub use arrayformat::PRINT_ELEMENTS_LIMIT; |
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'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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
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.
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_LIMIT
constant.