tensorflow / agents
Unit Size

The distribution of size of units (measured in lines of code).

Intro
  • Unit size measurements show the distribution of size of units of code (methods, functions...).
  • Units are classified in four categories based on their size (lines of code): 1-20 (small units), 20-50 (medium size units), 51-100 (long units), 101+ (very long units).
  • You should aim at keeping units small (< 20 lines). Long units may become "bloaters", code that have increased to such gargantuan proportions that they are hard to work with.
Learn more...
Unit Size Overall
  • There are 1,917 units with 23,702 lines of code in units (84.0% of code).
    • 13 very long units (1,621 lines of code)
    • 65 long units (4,382 lines of code)
    • 253 medium size units (8,017 lines of code)
    • 293 small units (4,290 lines of code)
    • 1,293 very small units (5,392 lines of code)
6% | 18% | 33% | 18% | 22%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py6% | 18% | 33% | 18% | 22%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
tf_agents/agents18% | 33% | 27% | 12% | 8%
tf_agents/bandits6% | 21% | 37% | 12% | 21%
tf_agents/policies11% | 16% | 34% | 19% | 18%
tf_agents/networks7% | 8% | 50% | 16% | 16%
tf_agents/replay_buffers0% | 22% | 41% | 11% | 24%
tf_agents/utils0% | 10% | 35% | 27% | 26%
tf_agents/environments0% | 8% | 26% | 20% | 44%
tf_agents/train0% | 18% | 37% | 19% | 24%
tf_agents/keras_layers0% | 24% | 0% | 43% | 31%
tf_agents/trajectories0% | 14% | 42% | 18% | 24%
tf_agents/benchmark0% | 0% | 51% | 24% | 24%
tf_agents/distributions0% | 0% | 35% | 26% | 38%
ROOT0% | 0% | 55% | 22% | 22%
tf_agents/drivers0% | 0% | 44% | 22% | 33%
tf_agents/metrics0% | 0% | 13% | 31% | 54%
tools0% | 0% | 23% | 44% | 31%
tf_agents/eval0% | 0% | 40% | 47% | 12%
tf_agents0% | 0% | 100% | 0% | 0%
tf_agents/system0% | 0% | 0% | 28% | 71%
tf_agents/experimental0% | 0% | 0% | 39% | 60%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def __init__()
in tf_agents/policies/policy_saver.py
206 10 9
def _train()
in tf_agents/agents/ppo/ppo_agent.py
159 29 3
def __init__()
in tf_agents/agents/ppo/ppo_agent.py
146 13 31
def _loss()
in tf_agents/agents/categorical_dqn/categorical_dqn_agent.py
134 28 7
def __init__()
in tf_agents/agents/qtopt/qtopt_agent.py
117 18 32
def policy_gradient_loss()
in tf_agents/agents/ppo/ppo_agent.py
117 15 8
def __init__()
in tf_agents/bandits/policies/neural_linucb_policy.py
114 15 12
def __init__()
in tf_agents/bandits/agents/linear_bandit_agent.py
108 14 11
def __init__()
in tf_agents/agents/sac/sac_agent.py
108 8 29
def critic_loss()
in tf_agents/agents/td3/td3_agent.py
106 5 6
def __init__()
in tf_agents/networks/encoding_network.py
104 26 14
def __init__()
in tf_agents/bandits/agents/neural_linucb_agent.py
101 10 20
def _sample_continuous_and_transpose()
in tf_agents/policies/samplers/cem_actions_sampler_continuous_and_one_hot.py
101 14 6
def run()
in tf_agents/environments/trajectory_replay.py
98 6 3
def _train()
in tf_agents/agents/cql/cql_sac_agent.py
93 3 3
def _distribution()
in tf_agents/bandits/policies/boltzmann_reward_prediction_policy.py
92 23 3
def __init__()
in tf_agents/agents/td3/td3_agent.py
90 8 25
def __init__()
in tf_agents/agents/cql/cql_sac_agent.py
89 2 46
def _distribution()
in tf_agents/bandits/policies/linear_bandit_policy.py
87 11 3
def total_loss()
in tf_agents/agents/reinforce/reinforce_agent.py
86 9 5