MCPcopy Index your code
hub / github.com/numpy/numpy / temppath

Function temppath

numpy/testing/_private/utils.py:2204–2222  ·  view source on GitHub ↗

Context manager for temporary files. Context manager that returns the path to a closed temporary file. Its parameters are the same as for tempfile.mkstemp and are passed directly to that function. The underlying file is removed when the context is exited, so it should be closed at t

(*args, **kwargs)

Source from the content-addressed store, hash-verified

2202
2203@contextlib.contextmanager
2204def temppath(*args, **kwargs):
2205 """Context manager for temporary files.
2206
2207 Context manager that returns the path to a closed temporary file. Its
2208 parameters are the same as for tempfile.mkstemp and are passed directly
2209 to that function. The underlying file is removed when the context is
2210 exited, so it should be closed at that time.
2211
2212 Windows does not allow a temporary file to be opened if it is already
2213 open, so the underlying file must be closed after opening before it
2214 can be opened again.
2215
2216 """
2217 fd, path = mkstemp(*args, **kwargs)
2218 os.close(fd)
2219 try:
2220 yield path
2221 finally:
2222 os.remove(path)
2223
2224
2225class clear_and_catch_warnings(warnings.catch_warnings):

Callers 15

test_fromfile_bogusMethod · 0.90
test_fromfile_complexMethod · 0.90
test_fromfileMethod · 0.90
test_genfromtxtMethod · 0.90
test_loadtxtMethod · 0.90
test_tofile_roundtripMethod · 0.90
test_tofile_fromfileMethod · 0.90
test_load_non_npyMethod · 0.90
test_big_arraysMethod · 0.90
writerMethod · 0.90

Calls 1

closeMethod · 0.45

Tested by 15

test_fromfile_bogusMethod · 0.72
test_fromfile_complexMethod · 0.72
test_fromfileMethod · 0.72
test_genfromtxtMethod · 0.72
test_loadtxtMethod · 0.72
test_tofile_roundtripMethod · 0.72
test_tofile_fromfileMethod · 0.72
test_load_non_npyMethod · 0.72
test_big_arraysMethod · 0.72
writerMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…