-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraph.py
More file actions
70 lines (51 loc) · 1.3 KB
/
graph.py
File metadata and controls
70 lines (51 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# coding=utf-8
"""
@file: graph.py
@data: 06 February 2023
@author: cecabert
Graph profiling samples
"""
import re
from pyprofiler.profiler import ProfilerCase
from pyprofiler.utils.decorator import accept_profiler
def compile():
return re.compile('^[abetors]*$')
def match(reo):
[reo.match(a) for a in words()]
def words():
return ['abbreviation',
'abbreviations',
'abettor',
'abettors',
'abilities',
'ability',
'abrasion',
'abrasions',
'abrasive',
'abrasives']
class Banana:
def eat(self):
pass
class Person:
def __init__(self):
self.no_bananas()
def no_bananas(self):
self.bananas = []
def add_banana(self, banana):
self.bananas.append(banana)
def eat_bananas(self):
[banana.eat() for banana in self.bananas]
self.no_bananas()
class GraphCases(ProfilerCase):
@accept_profiler('callgraph')
def profile_execution_graph(self):
# Compile
reo = compile()
match(reo=reo)
@accept_profiler('callgraph')
def profile_bananas(self):
# Eat 10 bananas
person = Person()
for a in range(10):
person.add_banana(Banana())
person.eat_bananas()