-
Notifications
You must be signed in to change notification settings - Fork 169
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
[stdlib_io] disp
(display your data)
#445
Conversation
1. src/stdlib_io_disp.fypp 2. src/tests/string/test_io_disp.f90 3. stdlib_io.fypp%disp interface modify: 1. doc/spec/stdlib_io.md%disp(doc) 2. src/Makefile.manual%disp(make) 3. src/tests/string/Makefile.manual%disp(make) 4. src/CMakelists.txt%disp(cmake) 5. src/CMakelists.txt%disp(cmake) note: make test passed. cmake test passed
Thanks @zoziha, @St-Maxwell for opening those pull requests. I think it is fine to have two PRs here, we will first discuss on #444 about the string formatting routines and once we agree on the API we will continue with the review of the display function. How does the plan sound to you? |
--- - stdlib_io.fypp 1. add disp interface comments 2. remove `impure` label - stdlib_io_disp.fypp 1. remove `non_intrinsic` label 2. update some `format_string` to `to_string` 3. update `fmt_r` & `fmt_c` 4. add some routine comments 5. update the writing of some statements - update test_io_disp.f90 - notes 1. make passed 2. cmake passed
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.
Strange discovery
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.
Thank you for this PR.
It might be good to submit 2 PRs, instead of one. It could help the reviewers.
Update `disp` docs; Adopt `select case` block; Adopt the `fypp` inline rank writing; Rename `disp` input arg: val -> value.
This comment has been minimized.
This comment has been minimized.
disp
(display your data) & format_string
(format other type to string)disp
(display your data) & format_string
(format other type to string, see #444)
I think the interface of |
The parameter output_unit is equivalent to the * in "write(*,'(a)')
'Hello'". Historically the value was 6, so that you may encounter
"write(6,*) ..." as well, but there is NO guarantee that LU-number 6
corresponds to the console. Before the introduction of output_unit and its
brethren it was not really possible to refer to "standard output" etc in a
standard way.
Op di 6 jul. 2021 om 05:50 schreef zoziha ***@***.***>:
… I may have some questions about the scheme of setting output_unit:
1. A single * Already means the default output location, which is the
same as [iso_fortran_env(module):output_unit(integer)] and belongs to
the standard output, or is it that I understand it wrong, they are
different?
2. Or your idea is to *add a input argument* for setting the
output_unit number to the disp subroutine.
If it is the latter, you will encounter such a problem, and the
polymorphic interface with two optional arguments will encounter such a
problem (see fortran interface optional
<https://stackoverflow.com/questions/3121954/fortran-90-presence-of-optional-arguments>).
At this time, it is better to consider rewriting a set of functions
disp(value [, string]) + disp(value, unit [, string]). (I can't express
what I mean very well)
The existing test (comment
<#445 (comment)>)
does not report an error if there is any issue, because it simply outputs
data to the screen (output_unit) and cannot be tested well. If the
output_unit scheme is improved, further testing may be possible.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#445 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAN6YRYCMED5L5Q3RKBBLF3TWJ4ORANCNFSM47KNB3SA>
.
|
This comment has been minimized.
This comment has been minimized.
Hello, I got a suggestion from @St-Maxwell and tried to implement it simply. I created a new branch disp_unit_brief in which I implemented Example(see stdlib_io.md/disp_example) disp(string):
string
It is a note.
disp(r):
[matrix size: 2×3]
-0.1000E-10 -0.1000E+11 1.000
1.000 1.000 1.000
disp(c):
[matrix size: 2×3]
(1.000,0.000) (1.000,0.000) (1.000,0.000)
(1.000,0.000) (-0.1000E+11,-0.1000E+11) (1.000,0.000)
disp(i):
[matrix size: 2×3]
1 1 1
1 1 1
disp(l):
[matrix size: 10×10]
T T T ... T
T T T ... T
T T T ... T
: : : : :
T T T ... T
disp(c_3d, 3):
[matrix size: 2×100]
(2.000,0.000) (2.000,0.000) (2.000,0.000) ... (2.000,0.000)
(2.000,0.000) (2.000,0.000) (2.000,0.000) ... (2.000,0.000)
disp(c_3d, 2):
[matrix size: 100×20]
(2.000,0.000) (2.000,0.000) (2.000,0.000) ... (2.000,0.000)
(2.000,0.000) (2.000,0.000) (2.000,0.000) ... (2.000,0.000)
(2.000,0.000) (2.000,0.000) (2.000,0.000) ... (2.000,0.000)
: : : : :
(2.000,0.000) (2.000,0.000) (2.000,0.000) ... (2.000,0.000) Reference links |
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.
Add support for string_type
type initially, and ready to get your feedback and update docs.
This PR is for stdlib_io_disp
routines, #444 PR is for stdlib_string_format_string
routines.
Thank you all~
Merge branch 'zoziha/feature/disp' into feature/disp_deep_brief
disp
(display your data) & format_string
(format other type to string, see #444)disp
(display your data)~~& format_string
(format other type to string, see #444)~~
disp
(display your data)~~& format_string
(format other type to string, see #444)~~disp
(display your data)
disp
(display your data)disp
(display your data)
Because call disp("It is a note.")
call disp(x, "I am a scalar:")
call disp(A(1:10, 2:4), "Let me see the array:") |
to_string
is merged.unit
argument:output_unit
brief
argument.brief
optional argument for users (see [stdlib_io]disp
(display your data) #445 (comment))disp
(display your data) #445 (comment))string_type
instdlib_string_type.fypp
(see [stdlib_io]disp
(display your data) #445 (review))linked list
(Stdlib linked list #491) indisp
would be a good addition. I am following it. (better not)This branch develops subroutines
disp
andformat_string
forstdlib
based on thedisp
andnum2str
functions in the forlab library.So, now
disp
API is:call [[stdlib_io(module):disp(interface)]]( [value, header, unit, brief] )
disp
subroutineEasily display strings, scalars and rank-1/rank-2 arrays to the screen (or another output
unit
).Effects
format_string
function(see #444)
Links