-
Notifications
You must be signed in to change notification settings - Fork 3
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
Issue 06/fix linting #7
Conversation
…atch` or `map...` instead of `if-else`
… have the more likely branch in the `if` rather than the `else`
src/lib.rs
Outdated
/// r_sparse.to_dense() | ||
/// ); | ||
/// } | ||
|
||
/// ``` |
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.
Minor fix: This code block closes twice
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.
Thanks for pointing this out!
Fixed by this commit
Tests still pass ✅
Thank you for such a well-organized pull request! The changes clearly improve the code, and indeed, the tests run slightly faster on my machine as well ( ~2.302s -> ~2.260s ). I am not a big fan of the auto-formatting on the test files because it adds a lot of new lines and makes the code slightly more inconvenient to navigate (at least for me). Nevertheless, I will admit that now the formatting is more consistent, so... Not really complaining. This pull request introduces breaking changes with respect to version 0.2.3; however, functionality has remained the same for the past year. I think it might be time to release v1.0.0 once these changes are merged. Once again, thank you for pointing out the errors in the code and taking the time to fix them. I appreciate the effort. EDIT: I was reviewing the code for a 1.0.0 release and this pull request is perfectly compatible with 0.2.3. |
Thanks for the positive feedback! 😊 I hope the reformatting of the tests does not make it too inconvenient 😖 Happy to hear that! There is not that many crates which went beyond the 0. major version 👏 Just out of curiositiy. Do you refer to the doctests only for the 2 seconds? |
The format will not be a problem! I am merging the pull request 🥳 About the tests, the full test suite runs in 2 seconds on my machine (Ryzen 7800X3D) when I run |
Nice 🥳 I didn't know that there is also a |
Maybe before going to major version 1:
I would really appreciate to hear your opinion on this. The first point is more an optional nice-to-have, though 😅 For the second point, the linear algebra library LAPACK (Fortran) offers the same functionality. For, e.g., banded Cholesky-based solvers, it offers:
So, something like this would be a standard way this could be approached 🤔 |
The initial scope of this project was to implement this book in Rust because I was building a thermal simulator for a specific academic application and I could not find a Rust solver that satisfied my needs (also, it was a good project for learning Rust). After I finished implementing the current set of features described in the book, I was not planning on building new features. In part because I have moved on from that project to other stuff. However, your proposal is in line with what this crate is, and so I am not against widening the scope of rsparse. Unfortunately, right now I do not have the time to implement those features and ensure they work correctly. If you are willing to build them, I would be glad to include them in the project. That said, this is a small project, and I am not sure I would be offering much value as a maintainer. |
This pull request implements the lint suggestions given when running
cargo clippy
:fn main {...}
from docstrings (all in one commit; can be undone if required)Vec<something>
to slices[something]
return
s (it is encouraged to not use them even though I think this is debatable)!vec
from testsBesides, it makes some tiny changes to make it more idiomatic here and there (mostly using⚠️ although a float-comparison with
match
ormap_or
for someif x.is_some()
) and also converts some highly predictablewhile
- to explicitfor
-loops (even though the compiler probably handled this gracefully all on its own).For the householder reflections 🪞 it flips the order of the
if sigma == 0
and theif sigma != 0
because the latter one is the more likely one to go. It should thus be the first in theif else
to make sure the CPU branch predictions are made properly by guessing it as the more likely branch first (==0
is mostly mathematically inspired, but due to floating point imprecisions this should probably be handled with some tolerances in the code instead; left aFIXME
).On top of that, it fixes a 🔤📖 typo here and there.
✅ The tests are all passing
⏱️ From a runtime perspective, the solver tests went from ~150 seconds execution time to ~120 seconds for a release build, but those timings were taken on a laptop, so take them with a grain of salt 🧂