facebookresearch / MathsFromExamples
Conditional Complexity

The distribution of complexity of units (measured with McCabe index).

Intro
  • Conditional complexity (also called cyclomatic complexity) is a term used to measure the complexity of software. The term refers to the number of possible paths through a program function. A higher value ofter means higher maintenance and testing costs (infosecinstitute.com).
  • Conditional complexity is calculated by counting all conditions in the program that can affect the execution path (e.g. if statement, loops, switches, and/or operators, try and catch blocks...).
  • Conditional complexity is measured at the unit level (methods, functions...).
  • Units are classified in four categories based on the measured McCabe index: 1-5 (simple units), 6-10 (medium complex units), 11-25 (complex units), 26+ (very complex units).
Learn more...
Conditional Complexity Overall
  • There are 125 units with 3,311 lines of code in units (91.5% of code).
    • 1 very complex units (213 lines of code)
    • 6 complex units (494 lines of code)
    • 19 medium complex units (1,068 lines of code)
    • 24 simple units (490 lines of code)
    • 75 very simple units (1,046 lines of code)
6% | 14% | 32% | 14% | 31%
Legend:
51+
26-50
11-25
6-10
1-5
Alternative Visuals
Conditional Complexity per Extension
51+
26-50
11-25
6-10
1-5
py6% | 14% | 32% | 14% | 31%
Conditional Complexity per Logical Component
primary logical decomposition
51+
26-50
11-25
6-10
1-5
src15% | 9% | 34% | 18% | 22%
src/envs0% | 21% | 35% | 10% | 33%
src/model0% | 22% | 25% | 27% | 24%
ROOT0% | 0% | 15% | 0% | 84%
Most Complex Units
Top 20 most complex units
Unit# linesMcCabe index# params
def enc_dec_step_beam_fast()
in src/evaluator.py
213 51 5
def gen_control()
in src/envs/ode.py
136 43 3
def generate_beam()
in src/model/transformer.py
84 38 7
def __init__()
in src/trainer.py
100 37 4
93 37 2
def __init__()
in src/envs/ode.py
57 36 7
24 33 4
def check_hypothesis()
in src/evaluator.py
64 22 1
def compare_gramians()
in src/evaluator.py
46 20 5
def fwd()
in src/model/transformer.py
55 17 8
80 16 1
def get_dump_path()
in src/utils.py
23 15 1
def generate_cond_init()
in src/envs/ode.py
70 15 5
def get_optimizer()
in src/optim.py
61 15 2
def check_gramian()
in src/evaluator.py
50 15 4
def enc_dec_step()
in src/evaluator.py
99 15 4
def __init__()
in src/envs/ode.py
134 14 2
def parse_float()
in src/envs/ode.py
33 14 2
def gen_fourier_cond_init()
in src/envs/ode.py
77 14 1
def forward()
in src/model/transformer.py
43 13 5