Find step for the passed range, which is based on 1, 2 or 5. Step returned will make sure that range fits 10..50 of them, as close to 10 as possible.
(valRange)
| 67 | self.inverse = inverse |
| 68 | |
| 69 | def getStep(valRange): |
| 70 | """ |
| 71 | Find step for the passed range, which is based on 1, 2 or 5. |
| 72 | Step returned will make sure that range fits 10..50 of them, |
| 73 | as close to 10 as possible. |
| 74 | """ |
| 75 | steps = {1: None, 2: None, 5: None} |
| 76 | for baseInc in steps: |
| 77 | baseIncAmount = valRange / baseInc |
| 78 | incScale = math.floor(math.log10(baseIncAmount) - 1) |
| 79 | steps[baseInc] = baseInc * 10 ** incScale |
| 80 | chosenBase = min(steps, key=lambda base: valRange / steps[base]) |
| 81 | chosenStep = steps[chosenBase] |
| 82 | if inverse: |
| 83 | chosenStep *= -1 |
| 84 | return chosenStep |
| 85 | |
| 86 | def getDigitPlaces(minValue, maxValue): |
| 87 | minDigits = 3 |
nothing calls this directly
no outgoing calls
no test coverage detected