MCPcopy Create free account
hub / github.com/pyfa-org/Pyfa / findCycles

Method findCycles

gui/builtinContextMenus/moduleSpool.py:54–74  ·  view source on GitHub ↗
(val1, val2)

Source from the content-addressed store, hash-verified

52 cycleTotalMax = max(cycleDefault, cycleCurrent, cycleMax)
53
54 def findCycles(val1, val2):
55 # Try to compose list of 21 steps max (0-20)
56 maxSteps = 20
57 valDiff = val2 - val1
58 valScale = valDiff / maxSteps
59 minStep = math.ceil(round(valScale, 9))
60 maxStep = math.floor(round(valDiff / 4, 9))
61 # Check steps from smallest to highest and see if we can go from min value
62 # to max value using those
63 for currentStep in range(minStep, maxStep + 1):
64 if valDiff % currentStep == 0:
65 return set(range(val1, val2 + currentStep, currentStep))
66 # Otherwise just split range in halves and go both ends using min values
67 else:
68 cycles = set()
69 while val2 >= val1:
70 cycles.add(val1)
71 cycles.add(val2)
72 val1 += minStep
73 val2 -= minStep
74 return cycles
75
76 self.cycleMap = {}
77 cyclesToShow = findCycles(cycleMin, cycleMax)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected