-
Notifications
You must be signed in to change notification settings - Fork 224
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
which(), image() and legend() don't support pathlib.Path inputs #1832
Comments
In Line 63 in 813142b
Perhaps we should refactor the
and in |
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 A couple other questions:
|
Yes, the plan is to refactor
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 |
Closed by #1837. |
I'm trying to fix a
pathlib
bug of plot and plot3d in #1831 and find thatwhich()
,image()
andlegend
also don't supportpathlib.Path
inputs.To reproduce the issue, run:
The error message is:
TypeError: sequence item 0: expected str instance, PosixPath found
.Other functions work because their input file is wrapped in a context manager, like
pygmt/pygmt/src/histogram.py
Lines 150 to 152 in 8fe2d33
To fix the bug, the simplest solution is changing input file to a string type, for example, changing
fname
tostr(fname)
. Do anyone have better and more general solutions?The text was updated successfully, but these errors were encountered: