Module:Interval edo approximation: Difference between revisions
m FloraC moved page Module:Interval Edo Approximation to Module:Interval edo approximation: WP: NCCAPS |
ArrowHead294 (talk | contribs) m Add debugger option, make code more friendly to read |
||
| Line 2: | Line 2: | ||
-- Calculates EDO approximations for just intervals | -- Calculates EDO approximations for just intervals | ||
-- Usage: {{#invoke:EDO_Approximations|main|interval=3/2|tolerance=9|min_edo=5|max_edo=60}} | -- Usage: {{#invoke:EDO_Approximations|main|interval=3/2|tolerance=9|min_edo=5|max_edo=60}} | ||
local yesno = require("Module:Yesno") | |||
local p = {} | local p = {} | ||
| Line 150: | Line 150: | ||
local ratio_cents = cents(ratio) | local ratio_cents = cents(ratio) | ||
-- Include subtitle info in caption to avoid breaking sortable functionality | -- Include subtitle info in caption to avoid breaking sortable functionality | ||
table.insert(output, string.format(' | table.insert(output, '|+ style="font-size: 105%;" | ' | ||
.. string.format('Edo approximations for %s (%.2f{{c}})<br /><span style="font-size: 0.75em;">\'\'≤ %dedo, relative error ≥ %g%%\'\'</span>', | |||
interval_str, ratio_cents, max_edo, tolerance)) | |||
table.insert(output, '|-') | table.insert(output, '|-') | ||
table.insert(output, '! Edo !! class="unsortable" | Step size !! Cents ([[cent|¢]]) !! Absolute error ([[cent|¢]]) !! [[Relative interval error|Relative error]] ([[relative cent|%]])') | table.insert(output, '! Edo' | ||
.. ' !! class="unsortable" | Step size' | |||
.. ' !! Cents ([[cent|¢]])' | |||
.. ' !! Absolute error ([[cent|¢]])' | |||
.. ' !! [[Relative interval error|Relative error]] ([[relative cent|%]])') | |||
for _, result in ipairs(results) do | for _, result in ipairs(results) do | ||
| Line 177: | Line 183: | ||
table.insert(output, '|}') | table.insert(output, '|}') | ||
local result = table.concat(output, '\n') | |||
if yesno(frame.args["debug"]) == true then | |||
result = '<syntaxhighlight lang="wikitext">' .. result .. '</syntaxhighlight>' | |||
end | |||
return frame:preprocess(result) | |||
end | end | ||
return p | return p | ||