我正在使用pycallgraph (从一个jupyter笔记本中)来理解我正在做的代码库。由于某些原因,GlobbingFilter似乎无法工作--我不能排除使用GlobbingFilter的东西
from pycallgraph import PyCallGraph, Config, GlobbingFilter
from pycallgraph.output import GraphvizOutput
from PIL import Image
import numpy as np
gv = GraphvizOutput()
gv.output_file = 'basic2.png'
config = Config()
config.trace_filter = GlobbingFilter(
exclude=['pycallgraph.*', '*__init__*'], include=['__main__'])
class Apple:
def __init__(self):
pass
def eat(self):
pass
class Basket:
def __init__(self):
self.content = []
def add(self, other):
self.content.append(other)
with PyCallGraph(output=gv, config=config):
a = Apple()
b = Basket()
b.add(a)
b.content[0].eat()
Image.open(gv.output_file)输出映像包含__init__方法。对如何去除它们有什么想法吗?此外,我也不能排除班级和他们的孩子(例如。Apple)
Ps。我使用的是callgraph4py (如果是pycallgraph,则是一个人用的叉子)

发布于 2022-02-02 18:08:56
这是一个简单的修复--如果我安装的库将GlobbingFilter功能注释掉的版本。
参见此处的第208行:https://github.com/e-alizadeh/pycallgraph/blob/master/pycallgraph/tracer.py

取消评论第208和209行修复了我的问题。
https://stackoverflow.com/questions/70959500
复制相似问题