Module:Harmonics in equal: Difference between revisions

Default number of columns set to 11. Cut off is now at 31 for prime, 23 for odd, and 12 for integer
Enable collapsing
Line 18: Line 18:
end
end


local function approx(steps, num, denom, intervals, title, prec, reduction)
local function approx(steps, num, denom, intervals, title, prec, reduction, collapsed)
local thead
if collapsed then
thead = '{| class="wikitable center-all mw-collapsible mw-collapsed"\n'
else
thead = '{| class="wikitable center-all"\n'
end
local tpri = {'! colspan="2" | Harmonic '}
local tpri = {'! colspan="2" | Harmonic '}
local tabs = {'! rowspan="2" | Error \n! absolute ([[cent|¢]]) '}
local tabs = {'! rowspan="2" | Error \n! absolute ([[cent|¢]]) '}
local trel = {'! [[Relative interval error|relative]] (%) '}
local trel = {'! [[Relative interval error|relative]] (%) '}
local tdeg = {'! colspan="2" | Step'}
local tdeg
if reduction then
if reduction then
tdeg = {'! colspan="2" | Steps<br>([[Octave_reduction|reduced]])'}
tdeg = {'! colspan="2" | Steps<br>([[Octave reduction|reduced]])'}
else
tdeg = {'! colspan="2" | Step'}
end
end
local fmt_abs = string.format(' %%+.%df', prec)
local fmt_abs = string.format(' %%+.%df', prec)
Line 44: Line 52:
local titleMarkup = ''
local titleMarkup = ''
if title then
if title then
titleMarkup = '|-\n|+ ' .. title .. '\n'
titleMarkup = '|-\n|+style=white-space:nowrap| ' .. title .. '\n'
end
end
return '{| class="wikitable center-all"\n' ..
return thead ..
titleMarkup ..
titleMarkup ..
'|-\n' ..
'|-\n' ..
Line 99: Line 107:
-- option intervals
-- option intervals
local select_intervals = "integer"
local select_intervals = "integer"
 


local name = steps .. 'ed' .. num .. '/' .. denom
local name = steps .. 'ed' .. num .. '/' .. denom
Line 142: Line 150:
reduction = false
reduction = false
end
end
return approx( steps, num, denom, {unpack(intervals[select_intervals], start, start+columns-1)}, title, prec, reduction)
local collapsed = frame.args['collapsed']
return approx( steps, num, denom, {unpack(intervals[select_intervals], start, start+columns-1)}, title, prec, reduction, collapsed)
end
end


return p;
return p;