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
Checking the existence of GMTTempFile using "os.path.exists" is invalid #1912
assertos.path.exists(path=tmpfile.name) # check that outfile exists
The problem is, GMTTempFile always creates the 0-byte temporary file when GMTTempFile is called, so the temporary file always exists. It means that we can't use os.path.exists to check if functions like grd2xyz write output to a file or not.
changed the title [-]Checking the existence of GMTTempFile using "os.path.exists" are invalid[/-][+]Checking the existence of GMTTempFile using "os.path.exists" is invalid[/+]on May 6, 2022
Activity
[-]Checking the existence of GMTTempFile using "os.path.exists" are invalid[/-][+]Checking the existence of GMTTempFile using "os.path.exists" is invalid[/+]maxrjones commentedon May 12, 2022
A third possible solution is to use info/grdinfo to check that the contents are generally as expected.
seisman commentedon May 13, 2022
We decided to use
xarray.testingrather thanpygmt.grdinfofor testing grids.seisman commentedon Dec 4, 2022
The
GMTTempFileclass is implemented based on theNamedTempoaryFileclass. I think it's not a good idea to change the default behavior.I think this is the way to go, and
Path.stat().st_sizeis a better choice.