Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1085 +/- ##
==========================================
- Coverage 68.52% 68.42% -0.11%
==========================================
Files 396 399 +3
Lines 12746 12866 +120
Branches 1376 1389 +13
==========================================
+ Hits 8734 8803 +69
- Misses 4012 4063 +51 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Thanks for this @fiolj. Would you mind reverting the changes not related to the implementation? (styling) There are too many and it renders difficult to read through the PR. You can check the style_guide for info https://github.com/fortran-lang/stdlib/blob/master/STYLE_GUIDE.md One thing, white spaces in-between parentheses and an intrinsic function are not recommended ( |
|
Thanks @jalvesz, I've fixed the formatting |
|
Reviewing the arguments of Currently, we have the order of |
Yes. I've commited some tests. |
I'm also confused now, codecov is supposed to ignore files in the examples directory after the PR #1074 ... I would say for the moment to ignore this false error. |
There was a problem hiding this comment.
Pull request overview
This PR adds optional arguments to the savetxt function to provide more flexibility when saving 2D arrays to text files, making it more similar to NumPy's savetxt functionality.
Changes:
- Added ability to specify an already-opened file unit instead of a filename, enabling writing to stdout or appending to files
- Added optional
headerandfooterparameters that are automatically commented with a configurable comment character - Added optional
fmtparameter to customize output format - Modified format string construction to support custom delimiters (though delimiter parameter still limited to single character)
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 18 comments.
| File | Description |
|---|---|
| src/io/stdlib_io.fypp | Core implementation: generates two variants of savetxt (filename and unit), adds format customization, header/footer support via new prepend helper function |
| test/io/test_savetxt.f90 | Updated tests to exercise new delimiter, fmt, header, footer, and comments parameters |
| doc/specs/stdlib_io.md | Updated documentation to describe new optional parameters and unit-based interface |
| example/io/example_savetxt.f90 | Added examples demonstrating new features including writing to stdout |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Jeremie Vandenplas <jeremie.vandenplas@gmail.com>
|
In my opinion it has converged, I would be happy to make changes if necessary. Could we get a new review and try to complete the task and merge this PR? |
src/io/stdlib_io.fypp
Outdated
| #:else | ||
| inquire (unit=unit, opened=opened) | ||
| if(.not. opened) then | ||
| write (msgout,'(a,i0,a)') 'savetxt error: unit ',unit,' not open' |
Co-authored-by: Jeremie Vandenplas <jeremie.vandenplas@gmail.com>
|
Thanks @jvdp1 for the review.
|
Added: - comments with intent of variable `fout` - stop the program if unit file is not open - clean-up comments
Added clarification of use with filename and unit. Also added an example
|
I've updated the specs to clarify the behavior when the file already exists (as suggested in the discussion thread):
|
I've been thinking on the suggestion on the the discussion thread) about consistency of the arguments. The use of an additional argument Syntax
Arguments...
The only problem that I can see is that when used with an unit number, the function will always be modifying the position of the file (to the beginning or the end). In the previous version the user could in principle position it arbitrarily. Thoughts, preferences? |
This PR aims to add optional arguments to
savetxt, that behave similar to numpy's savetxt.This is associated with Issue 263 and this discussion thread.
It add the possibility of supplying the unit of an open file instead of a filename (which could be used for
output_unitfor instance)This implementation is quite simple. The main changes are: