MCPcopy Create free account
hub / github.com/antirez/ds4 / nice_ceil

Function nice_ceil

speed-bench/plot_speed.py:25–35  ·  view source on GitHub ↗

Round a positive axis maximum up to a human-friendly tick boundary.

(value)

Source from the content-addressed store, hash-verified

23
24
25def nice_ceil(value):
26 """Round a positive axis maximum up to a human-friendly tick boundary."""
27 if value <= 0:
28 return 1.0
29
30 magnitude = 10 ** math.floor(math.log10(value))
31 normalized = value / magnitude
32 for step in (1, 2, 2.5, 3, 4, 5, 10):
33 if normalized <= step:
34 return step * magnitude
35 return 10 * magnitude
36
37
38def nice_step(span, target_ticks):

Callers 1

render_svgFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected