User:Johnuniq/Using the convert module

Module:Convert is ready to be considered as a replacement for the convert templates. This page shows what needs to be considered, and I hope people will comment at Template talk:Convert or at the talk page here. Johnuniq (talk) 11:06, 16 September 2013 (UTC)

Proposal

 * Allow two weeks for further testing of the module, and to overcome the roadblocks below.
 * On an arranged date, say 1 October 2013, replace Template:Convert with Template:Convert/sandboxlua for an evaluation period.
 * If any serious problems arise that cannot be quickly resolved, restore the template.

MediaWiki developers want high-overhead templates replaced with modules and are not concerned about the impact on the servers from making changes like this.

Would the wikitext currently at Template:Convert work if moved to another name? That would allow comparisons between the current template and the module to be made after replacing Template:Convert with the module version.

See the convert documentation.

Roadblocks
✅ All issues here are either fixed, or were ok in the first place. Johnuniq (talk) 21:59, 24 November 2013 (UTC)

The module may have problems which would need to be fixed before its use. These are documented here.

Templates dependent on convert
Are there any templates (such as infoboxes) that call the current Template:Convert, and which rely on a feature of that template that is not supported by the module?

Torque or energy
The module requires the output and input units to have the same "type", where the type is a name assigned to the unit. For example, currently  is type "torque", and   is type "energy". That means it is not possible to convert between those units:
 * Update After finding a few hundred converts using constructs like the following, I decided to fix the module to accept certain energy units so they would convert to/from Nm, so the following examples now work. Johnuniq (talk) 22:37, 26 September 2013 (UTC)
 * → 1200 Nm
 * → 1200 Nm
 * → 1200 Nm

If required, the module can make an exception for. Is it required? Do any other units have the magic property of being a certain type in one conversion, and a different type in another conversion?

Population density

 * Update After finding a couple of converts that mix the following types (although there appears no reason to do so), I've decided to change all the "population density" units to "per unit area" so there is no restriction on converting between them. Before that change, the second example below gave an error. Johnuniq (talk) 02:16, 27 September 2013 (UTC)
 * → 500 PD/sqmi

I'm not sure what should happen with units like these. Presumably, they should be of the same type so there is no dimension mismatch? That would allow conversions between any of the units listed at Population density and Per unit area.

Calorie or calorie
WP:MOSNUM states that the symbol  refers to a gram calorie, whereas   refers to a kilogram calorie.
 * Update It looks like the module is correct. Johnuniq (talk) 21:59, 24 November 2013 (UTC)

The definitions used by the module need to be checked: search for "calorie" at Conversion data, and see the differences at the power testcases.

Convert/x
If required, articles using convert/x (Convert/2, Convert/3, Convert/4, Convert/f, Convert/flip, Convert/flip2, Convert/flip3, Convert/flip4, Convert/scale, Convert/spell) would need to be checked and possibly manually adjusted to use the module. In a small number of cases, a wording workaround would be required as the module does not support arbitrary join text between items in a range (only predefined terms like "to" are possible).

Any converts that use 0 to mean "use the default output unit" would need to be adjusted because the module always interprets 0 as a rounding precision.

Unit definitions
The units used by the module are defined at Conversion data. Nearly all the data was copied from the templates created by Jimp and it would not have been possible to develop the module without the extremely accurate and thorough unit definitions in the templates.

New units can be quickly added by editing Module:Convert/extra, but the conversion data page should be regarded as the master list of units.

Testcases
Many test pages, and an accompanying module were created by WOSlinker. The tests compare the outputs from the current Template:Convert with the output from Template:Convert/sandboxlua. Following is a summary of the results as at 16 September 2013.


 * acceleration ∙ equivalent
 * area ∙ 3 differences; 2 link disagreements
 * area2 ∙ 1 difference due to a newline in the template output
 * density ∙ equivalent except for the module failing to use nowrap in one case
 * energy ∙ equivalent
 * energy2 ∙ 4 differences due to a default output disagreement; the link disagreements are trivial as they go, via a redirect, to the same page
 * energy3 ∙ equivalent
 * energy4 ∙ equivalent
 * energyperlength ∙ several link disagreements
 * energypermass ∙ equivalent
 * energypervolume ∙ several link disagreements
 * exhaustemission ∙ equivalent
 * flow ∙ 3 minor differences (1 in the wikitext, 2 due to links); several link disagreements
 * force ∙ several link disagreements
 * fuelconsumption ∙ 4 template errors; several link disagreements
 * gradient ∙ equivalent
 * length ∙ equivalent
 * length2 ∙ two "micro" differences
 * lineardensity ∙ equivalent
 * mass ∙ minor differences and one template error
 * mole ∙ three "micro" differences
 * per ∙ 3 differences where the template uses "US gal" while the module uses "U.S. gal"; 2 link disagreements where template should link to pound (mass)
 * populationdensity ∙ 6 minor link disagreements
 * power ∙ 5 serious differences due to calorie vs. large calorie; 21 link disagreements
 * pressure ∙ equivalent
 * radioactivity ∙ equivalent
 * speed ∙ 2 template errors; 1 minor link disagreement
 * temperature ∙ 2 differences due to a rounding disagreement; 1 template error
 * change ∙ equivalent
 * time ∙ 2 module "unknown unit" errors
 * torque ∙ lots of differences; module needs to be fixed as indicated above, and some unit properties may need fixing in the module
 * volume ∙ several link disagreements
 * volume2 ∙ 2 differences where the module probably should include "imperial" in name/unit; 2 disagreements about "litre" vs. "liter"; several link disagreements
 * volume3 ∙ several link disagreements
 * volume4 ∙ 1 difference where the module probably should use plural "kennings"; several link disagreements
 * volume5 ∙ 1 difference where the module probably should use plural "kennings"; 4 link disagreements
 * misc ∙ 3 module "unknown unit" errors; 2 message differences; several link disagreements
 * warnings ∙ 4 different error messages
 * dualunit ∙ 1 difference due to a rounding disagreement
 * options ∙ 1 difference (template uses hyphen for minus); 13 template errors; 1 "US" vs. "U.S."
 * options2 ∙ 5 differences due to template using hyphen for minus; 2 differences are false positives; 5 template errors; 3 preunit disagreements; 4 differences due to the module using "US gal"; 1 link difference
 * tables ∙ differences regarding align right/center; template errors
 * spell ∙ many differences
 * range ∙ 6 differences

Module problems
It is likely that switching to the module would reveal several problems including unknown units. Editors may report quirks, or problems may be reported in the error categories:
 * Category:Convert invalid units ∙ Pages with an invalid unit in a convert are listed here.
 * Category:Convert invalid options ∙ Pages with an invalid option in a convert are listed here.

Only pages in the main (article) and template namespaces are listed in a category when a convert problem is detected.

In addition to the testcases, I have several thousand convert examples copied from various articles, and a test script shows that the module produces satisfactory results for these additional tests, so problems introduced by the module should be manageable.

Issues where the module is known to sometimes differ from the templates include use of  and whether a unit name should be singular or plural.

Template problems
Switching to the module may introduce problems, but the current templates have issues, some of which already show bad results in articles. It is possible that introducing the module would fix some existing problems, and that should be balanced against whatever new problems would be introduced.

Articles known to have convert problems are:
 * Banpo ∙ displays "Template:Convert/hect" due to use of " " instead of " " as a unit. There is no way to find such problems which may due to an expectation that a particular unit should exist, or may be due to a typo. Using the module, the article would be in the "unknown unit" category.
 * Barbarossa-class ocean liner ∙ displays "Template:Convert/Dual/LinAonDorSoff" due to problem with " ".
 * Dodge D Series ∙ displays several "Template:Convert/cu in" due to use of " " instead of " ".
 * Fathom ∙ displays four occurrences of "Template:Convert/track/disp/2".
 * Frederick Wheeler ∙ displays "Template:Convert/X" due to incorrect "X" in a range; previewing a correction with " " shows another error.
 * Iguazu Falls ∙ displays two results like "1,746 m3/s (61,660 cu ft)" where the output unit is missing "/s" due to a typo; since "/s" was intended for both input and output, the converted values are correct; the module would give a "dimension mismatch" error.
 * MISTRAM ∙ displays two occurrences of "Template:Convert/mm/s" due to undefined unit " ".
 * Secure Digital ∙ displays several "Template:Convert/LoffAinDnumberSoff".
 * Tactical development on the Western Front in 1917 displays "10 knots (0.0032 mi)" (a dimension mismatch) due to typo (" " has "kn" instead of, presumably, "km").

Several other problems are shown at Convert notes.