Uh oh!
There was an error while loading. Please reload this page.
RFC Allow for io.StringIO inputs to certain modules - #576
Conversation
There is a new 'buffer' data_kind which is intended for io.StringIO stream data. This 'buffer' data is passed into `legend` via an intermediate file created using the helper tempfile_from_buffer function.
weiji14
commented
Sep 7, 2020
@dr-glenn, do you want to try this branch using Happy to receive any feedback before we merge this. If it's good, we might get this in for the upcoming PyGMT v0.2.0 release 😁 |
seisman
commented
Sep 7, 2020
|
weiji14
commented
Sep 7, 2020
I'm a pretty new user of To be fair, we'll probably need to refactor this hacky implementation (writing to a tempfile and having GMT read that file) to use |
seisman
commented
Sep 7, 2020
Yes, that's another point. Without this PR, users just need to add a few lines of codes (maybe two or three) to write strings into a temporary file, and pass the file name to legend(), text() or any other modules. But here you add several lines of codes to support it, and these codes are most likely to be removed in the future. Not sure if it's really worth the complexity. |
weiji14
commented
Sep 7, 2020
Fair point, the code here is really just a convenience function to simplify maybe 4-5 lines of code: pygmt/pygmt/helpers/tempfile.py Lines 150 to 155 in 06ee891 As for whether it's worth it, there are some GMT Supplemental Modules that don't quite support virtualfiles yet (e.g. |
seisman
commented
Apr 12, 2022
@weiji14 I think it's time to refactor this PR, so that all functions can accept |
Description of proposed changes
Make a
tempfile_from_bufferbackend function forio.StringIOinputs. Will be useful for modules where:Figure.legend's 'spec' option (see also Allow Figure.legend to read from StringIO #571)x2sys_cross(see also Wrap x2sys_init and x2sys_cross #546 (comment))This is implemented as the 'hacky' Option 1 at #571 (comment).
Happy to discuss about the actual implementation details, such as:
See also:
Fixes#571
Reminders
make formatandmake checkto make sure the code follows the style guide.doc/api/index.rst.