| Conditions | 1 | 
| Total Lines | 56 | 
| Code Lines | 52 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | # encoding=utf8 | ||
| 16 | def __init__(self): | ||
| 17 | r"""Initialize benchmarks.""" | ||
| 18 | |||
| 19 |         self.benchmark_classes = { | ||
| 20 | "ackley": benchmarks.Ackley, | ||
| 21 | "alpine1": benchmarks.Alpine1, | ||
| 22 | "alpine2": benchmarks.Alpine2, | ||
| 23 | "bentcigar": benchmarks.BentCigar, | ||
| 24 | "chungReynolds": benchmarks.ChungReynolds, | ||
| 25 | "cosinemixture": benchmarks.CosineMixture, | ||
| 26 | "csendes": benchmarks.Csendes, | ||
| 27 | "discus": benchmarks.Discus, | ||
| 28 | "dixonprice": benchmarks.DixonPrice, | ||
| 29 | "conditionedellptic": benchmarks.Elliptic, | ||
| 30 | "elliptic": benchmarks.Elliptic, | ||
| 31 | "expandedgriewankplusrosenbrock": benchmarks.ExpandedGriewankPlusRosenbrock, | ||
| 32 | "expandedschaffer": benchmarks.ExpandedSchaffer, | ||
| 33 | "griewank": benchmarks.Griewank, | ||
| 34 | "happyCat": benchmarks.HappyCat, | ||
| 35 | "hgbat": benchmarks.HGBat, | ||
| 36 | "infinity": benchmarks.Infinity, | ||
| 37 | "katsuura": benchmarks.Katsuura, | ||
| 38 | "levy": benchmarks.Levy, | ||
| 39 | "michalewicz": benchmarks.Michalewichz, | ||
| 40 | "modifiedscwefel": benchmarks.ModifiedSchwefel, | ||
| 41 | "perm": benchmarks.Perm, | ||
| 42 | "pinter": benchmarks.Pinter, | ||
| 43 | "powell": benchmarks.Powell, | ||
| 44 | "qing": benchmarks.Qing, | ||
| 45 | "quintic": benchmarks.Quintic, | ||
| 46 | "rastrigin": benchmarks.Rastrigin, | ||
| 47 | "ridge": benchmarks.Ridge, | ||
| 48 | "rosenbrock": benchmarks.Rosenbrock, | ||
| 49 | "salomon": benchmarks.Salomon, | ||
| 50 | "schaffer2": benchmarks.SchafferN2, | ||
| 51 | "schaffer4": benchmarks.SchafferN4, | ||
| 52 | "schumerSteiglitz": benchmarks.SchumerSteiglitz, | ||
| 53 | "schwefel": benchmarks.Schwefel, | ||
| 54 | "schwefel221": benchmarks.Schwefel221, | ||
| 55 | "schwefel222": benchmarks.Schwefel222, | ||
| 56 | "sphere": benchmarks.Sphere, | ||
| 57 | "sphere2": benchmarks.Sphere2, | ||
| 58 | "sphere3": benchmarks.Sphere3, | ||
| 59 | "step": benchmarks.Step, | ||
| 60 | "step2": benchmarks.Step2, | ||
| 61 | "step3": benchmarks.Step3, | ||
| 62 | "stepint": benchmarks.Stepint, | ||
| 63 | "styblinskiTang": benchmarks.StyblinskiTang, | ||
| 64 | "sumSquares": benchmarks.SumSquares, | ||
| 65 | "trid": benchmarks.Trid, | ||
| 66 | "weierstrass": benchmarks.Weierstrass, | ||
| 67 | "whitley": benchmarks.Whitley, | ||
| 68 | "zakharov": benchmarks.Zakharov | ||
| 69 | } | ||
| 70 | |||
| 71 |         self.algorithm_classes = {} | ||
| 72 | |||
| 101 |