Module:Infobox interval: Difference between revisions

Plumtree (talk | contribs)
mNo edit summary
Plumtree (talk | contribs)
mNo edit summary
Line 16: Line 16:
local ratio_approx = rat.as_float(ratio)
local ratio_approx = rat.as_float(ratio)
local ratio_cents = rat.cents(ratio)
local ratio_cents = rat.cents(ratio)
local regular = not ratio.nan and not ratio.zero and not ratio.inf
local infobox_data = {}
local infobox_data = {}
Line 28: Line 30:
rat.factorisation(ratio)
rat.factorisation(ratio)
})
})
local subgroup = rat.subgroup(ratio)
if regular then
if subgroup and #subgroup > 0 and subgroup ~= 'n/a' then
table.insert(infobox_data, {
table.insert(infobox_data, {
'[[Just intonation subgroup|Subgroup]]',
'[[Just intonation subgroup|Subgroup]]',
subgroup
rat.subgroup(ratio)
})
end
if regular then
table.insert(infobox_data, {
'[[Monzo]]',
ratio_ket
})
table.insert(infobox_data, {
'Size in [[cent]]s',
i._to_cents(ratio_approx, 8)
})
})
end
end
table.insert(infobox_data, {
'[[Monzo]]',
ratio_ket
})
table.insert(infobox_data, {
'Size in [[cent]]s',
i._to_cents(ratio_approx, 8)
})


local name = frame.args['Name']
local name = frame.args['Name']
Line 78: Line 81:
end
end
table.insert(infobox_data, {
if regular then
'Norms',
table.insert(infobox_data, {
'[[Tenney height|log<sub>2</sub> n⋅d]]: ' .. u._round(rat.tenney_height(ratio), 6) .. '<br/>'
'Norms',
.. '[[Weil height|max(n, d)]]: ' .. u._round(rat.weil_height(ratio), 6) .. '<br/>'
'[[Tenney height|log<sub>2</sub> n⋅d]]: ' .. u._round(rat.tenney_height(ratio), 6) .. '<br/>'
.. '[[Benedetti height|n⋅d]]: ' .. u._round(rat.benedetti_height(ratio), 6)
.. '[[Weil height|max(n, d)]]: ' .. u._round(rat.weil_height(ratio), 6) .. '<br/>'
})
.. '[[Benedetti height|n⋅d]]: ' .. u._round(rat.benedetti_height(ratio), 6)
})
end
if not ratio.zero and not ratio.inf then
if regular then
table.insert(infobox_data, {
table.insert(infobox_data, {
'[[Harmonic entropy]]',
'[[Harmonic entropy]]',