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

Function short_path

tools/refguide_check.py:111–133  ·  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

109
110
111def short_path(path, cwd=None):
112 """
113 Return relative or absolute path name, whichever is shortest.
114
115 Parameters
116 ----------
117 path : str or None
118 cwd : str or None
119
120 Returns
121 -------
122 str
123 Relative path or absolute path based on current working directory
124 """
125 if not isinstance(path, str):
126 return path
127 if cwd is None:
128 cwd = os.getcwd()
129 abspath = os.path.abspath(path)
130 relpath = os.path.relpath(path, cwd)
131 if len(abspath) <= len(relpath):
132 return abspath
133 return relpath
134
135
136def find_names(module, names_dict):

Callers 1

check_restFunction · 0.85

Calls 1

abspathMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…