MCPcopy Create free account
hub / github.com/numpy/numpy / short_path

Function short_path

tools/refguide_check.py:157–179  ·  view source on GitHub ↗

Return relative or absolute path name, whichever is shortest. Parameters ---------- path : str or None cwd : str or None Returns ------- str Relative path or absolute path based on current working directory

(path, cwd=None)

Source from the content-addressed store, hash-verified

155
156
157def short_path(path, cwd=None):
158 """
159 Return relative or absolute path name, whichever is shortest.
160
161 Parameters
162 ----------
163 path : str or None
164 cwd : str or None
165
166 Returns
167 -------
168 str
169 Relative path or absolute path based on current working directory
170 """
171 if not isinstance(path, str):
172 return path
173 if cwd is None:
174 cwd = os.getcwd()
175 abspath = os.path.abspath(path)
176 relpath = os.path.relpath(path, cwd)
177 if len(abspath) <= len(relpath):
178 return abspath
179 return relpath
180
181
182def find_names(module, names_dict):

Callers 2

check_restFunction · 0.85
_run_doctestsFunction · 0.85

Calls 1

abspathMethod · 0.45

Tested by

no test coverage detected