You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
which(), image() and legend() don't support pathlib.Path inputs #1832
To fix the bug, the simplest solution is changing input file to a string type, for example, changing fname to str(fname). Do anyone have better and more general solutions?
Does anyone have comments on the proposed refactor in #1837?
I like the idea in general. I would rather that all modules handle input and output using the same strategy rather than only applying this code structure to these three methods/functions. Would you be open to a larger refactor using the new build_arg_string input and output arguments in other functions/methods for consistency?
A couple other questions:
Should we do any type checking before converting to a string?
Does anyone have comments on the proposed refactor in #1837?
I like the idea in general. I would rather that all modules handle input and output using the same strategy rather than only applying this code structure to these three methods/functions. Would you be open to a larger refactor using the new build_arg_string input and output arguments in other functions/methods for consistency?
Yes, the plan is to refactor build_arg_string in all functions.
Should we do any type checking before converting to a string?
Perhaps not necessary now. From what I see, infile/outfile is either a string, a pathlib.Path object or a virtual file (also a string), so converting everything to a string looks OK.
Activity
seisman commentedon Mar 19, 2022
In
pygmt.which()or other functions, we build the argument string using the following code:pygmt/pygmt/src/which.py
Line 63 in 813142b
Perhaps we should refactor the
build_arg_stringfunction to:and in
build_arg_string, we always make sure thatinfileandoutfileare converted to string type.seisman commentedon Mar 29, 2022
Does anyone have comments on the proposed refactor in #1837?
maxrjones commentedon Mar 29, 2022
I like the idea in general. I would rather that all modules handle input and output using the same strategy rather than only applying this code structure to these three methods/functions. Would you be open to a larger refactor using the new
build_arg_stringinput and output arguments in other functions/methods for consistency?A couple other questions:
seisman commentedon Mar 30, 2022
Yes, the plan is to refactor
build_arg_stringin all functions.Perhaps not necessary now. From what I see, infile/outfile is either a string, a pathlib.Path object or a virtual file (also a string), so converting everything to a string looks OK.
Mention
pathlib.Pathin docstrings sounds a good idea. BTW, the planned tutorial at #1268 will also mentionpathlib.Pathsupport.seisman commentedon Apr 4, 2022
Closed by #1837.