MCPcopy
hub / github.com/piskvorky/gensim / get_tmpfile

Function get_tmpfile

gensim/test/utils.py:113–145  ·  view source on GitHub ↗

Get full path to file `suffix` in temporary folder. This function doesn't creates file (only generate unique name). Also, it may return different paths in consecutive calling. Parameters ---------- suffix : str Suffix of file. Returns ------- str Pat

(suffix)

Source from the content-addressed store, hash-verified

111
112
113def get_tmpfile(suffix):
114 """Get full path to file `suffix` in temporary folder.
115 This function doesn't creates file (only generate unique name).
116 Also, it may return different paths in consecutive calling.
117
118 Parameters
119 ----------
120 suffix : str
121 Suffix of file.
122
123 Returns
124 -------
125 str
126 Path to `suffix` file in temporary folder.
127
128 Examples
129 --------
130 Using this function we may get path to temporary file and use it, for example, to store temporary model.
131
132 .. sourcecode:: pycon
133
134 >>> from gensim.models import LsiModel
135 >>> from gensim.test.utils import get_tmpfile, common_dictionary, common_corpus
136 >>>
137 >>> tmp_f = get_tmpfile("toy_lsi_model")
138 >>>
139 >>> model = LsiModel(common_corpus, id2word=common_dictionary)
140 >>> model.save(tmp_f)
141 >>>
142 >>> loaded_model = LsiModel.load(tmp_f)
143
144 """
145 return os.path.join(tempfile.mkdtemp(), suffix)
146
147
148@contextlib.contextmanager

Callers 15

setUpMethod · 0.90
test_persistencyMethod · 0.90
test_largeMethod · 0.90
test_large_compressedMethod · 0.90
test_mmapMethod · 0.90
test_mmap_compressedMethod · 0.90
assertIndexSavedMethod · 0.90
test_saveMethod · 0.90
test_save_loadMethod · 0.90
assertIndexSavedMethod · 0.90

Calls

no outgoing calls

Tested by 15

setUpMethod · 0.72
test_persistencyMethod · 0.72
test_largeMethod · 0.72
test_large_compressedMethod · 0.72
test_mmapMethod · 0.72
test_mmap_compressedMethod · 0.72
assertIndexSavedMethod · 0.72
test_saveMethod · 0.72
test_save_loadMethod · 0.72
assertIndexSavedMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…