Find the first place in the stack that is not inside hvplot (tests notwithstanding). Inspired by: pandas.util._exceptions.find_stack_level
()
| 1215 | |
| 1216 | |
| 1217 | def _find_stack_level() -> int: |
| 1218 | """ |
| 1219 | Find the first place in the stack that is not inside hvplot |
| 1220 | (tests notwithstanding). |
| 1221 | Inspired by: pandas.util._exceptions.find_stack_level |
| 1222 | """ |
| 1223 | import hvplot |
| 1224 | |
| 1225 | pkg_dir = os.path.dirname(hvplot.__file__) |
| 1226 | test_dir = os.path.join(pkg_dir, 'tests') |
| 1227 | |
| 1228 | # https://stackoverflow.com/questions/17407119/python-inspect-stack-is-slow |
| 1229 | frame = inspect.currentframe() |
| 1230 | try: |
| 1231 | n = 0 |
| 1232 | while frame: |
| 1233 | filename = inspect.getfile(frame) |
| 1234 | if filename.startswith(pkg_dir) and not filename.startswith(test_dir): |
| 1235 | frame = frame.f_back |
| 1236 | n += 1 |
| 1237 | else: |
| 1238 | break |
| 1239 | finally: |
| 1240 | # See note in |
| 1241 | # https://docs.python.org/3/library/inspect.html#inspect.Traceback |
| 1242 | del frame |
| 1243 | return n |
| 1244 | |
| 1245 | |
| 1246 | def _generate_unique_name(name: str, names: Sequence[str], suffix: str = '_') -> str: |
no outgoing calls
no test coverage detected
searching dependent graphs…