Comments (8)
PyCG should produce a complete call graph in this case. This is probably a bug with the generator, I'll investigate when I got the bandwidth and get back to you.
from pycg.
Very thank you for your quick response!! It will be a great help for me. Actually I can provide another code snippet which may be related to the code above or an extension (about external library) of the code above. This code sample is as following:
def f_sample_2():
import numpy
import torch
numpy_array = numpy.ones(shape=[2,3])
torch_tensor = torch.ones(size=[2,3])
numpy_array.max()
torch_tensor.max()
The extracted callgraph is
["numpy.ones", "torch.ones"]
I think it maybe lack
numpy.ndarray.max and torch.Tensor.max
(Am I right? or is it within expectation? )
this new case involves the external library like numpy and torch. (I see your code involves handling external library, so in expectation your code can give the complete callgraph in this case?)
Looking forward to receiving your response.
from pycg.
Hello, I have read your work "PyCG: Practical Call Graph Generation in Python", and think it is valuable, helpful and insightful. However, when I try to scan this file as following:
class tmp_C: def tmp_f_in_c(self): print('tmp_f_in_c called') return None def tmp_f(): a = tmp_C returned = a() return returned def f_sample(): tmp_c = tmp_f() tmp_c.tmp_f_in_c()
the extracted callgraph is
{"small": ["small.f_sample"], "small.tmp_C.tmp_f_in_c": ["<builtin>.print"], "<builtin>.print": [], "small.tmp_f": [], "small.f_sample": ["small.tmp_f"]}
there is not 'small.tmp_C.tmp_f_in_c' in 'small.f_sample' 's calling function while 'small.f_sample' has called 'small.tmp_C.tmp_f_in_c'. So I'd ask whether your callgraph generator could extract this complete callgraph within expectation? It will be a great and wonderful help if you response me. Thank you!
I think PyCG is trying to look for class tmp_c
but tmp_c
is not defined anywhere in scope.
It will work if you change tmp_c.tmp_f_in_c()
to tmp_C.tmp_f_in_c()
{"small": [], "small.tmp_C.tmp_f_in_c": ["<builtin>.print"], "<builtin>.print": [], "small.tmp_f": [], "small.f_sample": ["small.tmp_f", "small.tmp_C.tmp_f_in_c"]}
from pycg.
Hello, I have read your work "PyCG: Practical Call Graph Generation in Python", and think it is valuable, helpful and insightful. However, when I try to scan this file as following:
class tmp_C: def tmp_f_in_c(self): print('tmp_f_in_c called') return None def tmp_f(): a = tmp_C returned = a() return returned def f_sample(): tmp_c = tmp_f() tmp_c.tmp_f_in_c()
the extracted callgraph is
{"small": ["small.f_sample"], "small.tmp_C.tmp_f_in_c": ["<builtin>.print"], "<builtin>.print": [], "small.tmp_f": [], "small.f_sample": ["small.tmp_f"]}
there is not 'small.tmp_C.tmp_f_in_c' in 'small.f_sample' 's calling function while 'small.f_sample' has called 'small.tmp_C.tmp_f_in_c'. So I'd ask whether your callgraph generator could extract this complete callgraph within expectation? It will be a great and wonderful help if you response me. Thank you!I think PyCG is trying to look for class
tmp_c
buttmp_c
is not defined anywhere in scope. It will work if you changetmp_c.tmp_f_in_c()
totmp_C.tmp_f_in_c()
{"small": [], "small.tmp_C.tmp_f_in_c": ["<builtin>.print"], "<builtin>.print": [], "small.tmp_f": [], "small.f_sample": ["small.tmp_f", "small.tmp_C.tmp_f_in_c"]}
Thank you for your response and help!
Since 'tmp_c' is the instance of 'tmp_C' as defined in 'tmp_f', do you mean PYCG technically can not detect 'tmp_c' is the instance of 'tmp_C'?
from pycg.
Hello, I have read your work "PyCG: Practical Call Graph Generation in Python", and think it is valuable, helpful and insightful. However, when I try to scan this file as following:
class tmp_C: def tmp_f_in_c(self): print('tmp_f_in_c called') return None def tmp_f(): a = tmp_C returned = a() return returned def f_sample(): tmp_c = tmp_f() tmp_c.tmp_f_in_c()
the extracted callgraph is
{"small": ["small.f_sample"], "small.tmp_C.tmp_f_in_c": ["<builtin>.print"], "<builtin>.print": [], "small.tmp_f": [], "small.f_sample": ["small.tmp_f"]}
there is not 'small.tmp_C.tmp_f_in_c' in 'small.f_sample' 's calling function while 'small.f_sample' has called 'small.tmp_C.tmp_f_in_c'. So I'd ask whether your callgraph generator could extract this complete callgraph within expectation? It will be a great and wonderful help if you response me. Thank you!I think PyCG is trying to look for class
tmp_c
buttmp_c
is not defined anywhere in scope. It will work if you changetmp_c.tmp_f_in_c()
totmp_C.tmp_f_in_c()
{"small": [], "small.tmp_C.tmp_f_in_c": ["<builtin>.print"], "<builtin>.print": [], "small.tmp_f": [], "small.f_sample": ["small.tmp_f", "small.tmp_C.tmp_f_in_c"]}
Thank you for your response and help! Since 'tmp_c' is the instance of 'tmp_C' as defined in 'tmp_f', do you mean PYCG technically can not detect 'tmp_c' is the instance of 'tmp_C'?
This is causing issue
a = tmp_C
returned = a()
PyCG can detect instance if the code looks like this
class tmp_C:
def tmp_f_in_c(self):
print('tmp_f_in_c called')
return None
def tmp_f():
a = tmp_C()
return a
def f_sample():
tmp_c = tmp_f()
tmp_c.tmp_f_in_c()
from pycg.
@seanxiaoyan yes, it is rare but it is grammatical in python.. Since the author says PYCG should detect it, I will wait for him to figure out it..
from pycg.
hello, would you mind me asking when this bug can be fixed?
from pycg.
Closing due to archival of repository.
from pycg.
Related Issues (20)
- Broken link HOT 1
- What tool have you used to generate the figures from JSON/FASTEN? HOT 1
- Can it be used to generate static backward slice? HOT 1
- what is the meaning of NEXT_MEHOD and ITER_METHOD? HOT 1
- list definition creation causes an infinite loop in the post processor HOT 1
- make test occur a error HOT 1
- Can PyCG optimize to flow sensitive? HOT 5
- PyCG fails when parsing files whose names are used in init file declarations HOT 1
- how to analyse cg of __init__.py HOT 2
- Possible to have option to exclude builtin functions? HOT 1
- Not being able to run PyCG from source due to circular import(?) HOT 2
- analysis does not follow explicit super()-calls HOT 2
- Add class def in addition to MRO HOT 1
- Relative/partial module path of class due to relative import HOT 8
- Does pycg work in colab? HOT 1
- PyCG can't support the analysis of function pointers in a call graph. HOT 1
- Ignore built-in functions, numpy, torch... HOT 2
- Detected non-deterministic results under various configurations HOT 3
- Handling posonlyargs HOT 2
- Install of `0.0.7` failing in GitHub actions HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pycg.