Skip to content

Conversation

@fiolj
Copy link
Contributor

@fiolj fiolj commented Jan 5, 2026

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_unit for instance)

This implementation is quite simple. The main changes are:

  1. Add optional header and footer (that could be commented out with a character, currently defaults to '#')
  2. Changes delimiter to an arbitrary length string. I am not completely sure that is really useful. Initially I've added this because np.savetxt (Numpy's) allows character or arbitrary strings but np.loadtxt requires it to be a length 1 char.
  3. Add the possibility to override default format for saving data

@codecov
Copy link

codecov bot commented Jan 5, 2026

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.64%. Comparing base (17a320a) to head (3f6aff3).

Files with missing lines Patch % Lines
example/io/example_savetxt.f90 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1085      +/-   ##
==========================================
- Coverage   68.67%   68.64%   -0.04%     
==========================================
  Files         393      393              
  Lines       12720    12724       +4     
  Branches     1376     1376              
==========================================
- Hits         8736     8734       -2     
- Misses       3984     3990       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jalvesz
Copy link
Contributor

jalvesz commented Jan 6, 2026

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 ( open (...), allocate (...), etc )

@jalvesz jalvesz linked an issue Jan 6, 2026 that may be closed by this pull request
@fiolj
Copy link
Contributor Author

fiolj commented Jan 6, 2026

Thanks @jalvesz, I've fixed the formatting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add optional arguments to savetxt

2 participants