Jump to content

Баҳси шаблон:Convert/nesting

Page contents not supported in other languages.
Мавод аз Википедиа — донишномаи озод

This is the talk-subpage for: Template:Convert/nesting.


11-March-2010: This page is used to discuss issues about the depth of nest-levels of the multi-nested subtemplates in Template:Convert. There are related talk-subpages:

Also see: Template_talk:Convert - for general discussion.
Also see: Template_talk:Convert/density - about density conversions.
Also see: Template_talk:Convert/updates - for requesting protected updates.

This talk-subpage is intended to discuss changes to improve the nesting, or improve the explanations, or to help determine the nest-level of a conversion. -Wikid77 (talk) 10:43, 10 March 2010 (UTC)

New rounding routine for less nesting

[вироиши манбаъ]

11-March-2010: There is a new, simplified rounding subtemplate, {{rndpad}}, which is intended to bypass the complex, scientific notation rounder, {{rnd}}, except for extremely large amounts. For amounts above 85 billion, or rounding above 99 thousand (where n < -5), the full Template:Rnd should be used. However, for most amounts, there is no need to prepare for scientific notation, so the rounding could be done much faster and simpler by {{rndpad}}, which can show 10-digit amounts, while also padding for trailing-zeroes in decimal results.

The planned update, to begin using {{rndpad}}, would require changing {{Convert/round}} to invoke "rndpad" rather than "rnd" (with the same parameters). However, those changes should be tested in sandbox versions of the subtemplates. -Wikid77 10:43, 10 March 2010, revised 20:09, 16 January 2011 (UTC)

Notice of updating Rnd to bypass Rnd/a

[вироиши манбаъ]

11-April-2010: This is just an FYI that Template:Rnd has been updated (on 5 April 2010) to bypass the small subtemplate {Rnd/a} to reduce Convert nesting by 1 more level, against the template-nesting limit. This change affected nearly 307,000 pages, and dropped 307,000 wikilinks to {Rnd/a}, which then became almost unused. See counts in database report:

The full talk-page topics are in Template_talk:Rnd:

Those topics describe the issue, with examples. After update, then 305,700 articles were auto-reformatted to de-link {Rnd/a} (within 5 hours on a Sunday night). However, another 1,195 articles were "stuck" as still linking to the unused {Rnd/a}, but hundreds per day later de-linked it, after each article was edited by the pool of thousands of active editors. -Wikid77 18:03, 11 April 2010 (UTC)

Convert uses 17-30 of 40 limit

[вироиши манбаъ]

17-Nov-2010: While it is true that the complexity of Convert's if-logic and nested subtemplates uses about half of the MediaWiki (1.6) expression-nest limit of 40 levels, Convert is NEVER "near" that transclusion depth limit, by itself. When precision is specified as "sigfig=3" or round "0" then Convert uses only 17 nest-levels, leaving 23 available (see examples below). Instead, some of the {Infobox} plus {Documentation} templates have been using more than 11(!) nest levels, of nested subtemplates or if-else logic, before invoking Convert. Although many people might have trouble seeing why Convert of 77 inches to "ft m" (feet-and-metres) uses 29 levels of nested logic, the concept of any {Infobox} template using 8 or 11 levels, of nested logic, totally baffles me. I have run tests which prove that an infobox-table (class=infobox), of couse, causes no nesting, at all. The 8-to-11 levels are caused by complex {Infobox} templates. This is another reason why the current transclusion depth limit of 40 is just too small for the real world: people are creating generalized infoboxes which nest 8-to-11 levels deep, before invoking Convert inside them. Again, the good news is that people can typically specify sigfig=3 or round "0" in many cases, and reduce Convert by the 11 nest-levels used to determine the precision of the input number. In those cases, that allows people to complicate infoboxes by another 11 levels deep.

Nest 23 templates
inside Infobox
{convert|12|km|mi|0} →
12 километр (7 mi)
   
  

The following are several live examples which demonstrate that Convert can be used inside templates nested 12 levels deep, or 22 deep for sigfig=3 or round "0" (and such). Specifying the precision will free another 11 levels, so that Convert, with precision, uses less than half of the total limit.

: Nest 23 templates - {convert|12|km|mi|0}:
{{1x|{{1x|{{1x|{{1x|{{1x|{{1x|{{1x|{{1x|{{1x|{{1x
|{{1x|{{1x|{{1x|{{1x| {{1x|{{1x|{{1x|{{1x|{{1x|{{1x
|{{1x|{{1x
| {{convert|12|km|mi|0}}
}}}} }}}} }}}} }}}} }}}} }}}} }}}} }}}} }}}} }}}}
}}}}
Nest 23 templates - {convert|12|km|mi|0}:   12 километр (7 mi)


: Nest 13 templates - typical {convert|45|km|mi}:
{{1x|{{1x|{{1x|{{1x|{{1x|{{1x|{{1x|{{1x|{{1x|{{1x|{{1x|{{1x
| {{convert|45|km|mi}}
}}}} }}}} }}}} }}}} }}}} }}}}
Nest 13 templates - typical {convert|45|km|mi}: 45 километр (28 mi)
: Nest 11 templates - Dual-output {convert|67|km|ft m}:
{{1x|{{1x|{{1x|{{1x|{{1x|{{1x|{{1x|{{1x|{{1x|{{1x
| {{convert|67|km|ft m}}
}}}} }}}} }}}} }}}} }}}}
Nest 11 templates - Dual-output {convert|67|km|ft m}:   67 километр (220,000 ft; 67,000 м)


Having 2 dual output amounts, such as "ft m" increases the Convert nesting by 2 more levels. In all cases I have seen, Convert uses less than 30 of the 40 total nesting levels allowed in 2009-2010. Setting the precision, sigfig=3 or round "0" will free another 11 levels. -Wikid77 (talk) 05:14, 17 November 2010, revised 15:30, 6 November 2012 (UTC)

Reducing the nested templates

[вироиши манбаъ]

17-Nov-2010: Some reduction of nested templates, used inside the convert calculations, has already been done:

  • Template:Rnd was changed to bypass Template:Rnd/a.
  • [[Template:xx] was changed to bypass Template:xx/a.

Similarly, Template:Precision is being modified to bypass Template:Precision/a, which had merely allowed 2 instances of parser-function {#titleparts:xxxx|1|2} to be specified as parameter {2} passed into {Precision/a}. Because Template:Precision, and its subtemplates, has been using 8 levels of nesting, it has been discussed for years as an area to reduce the nesting.

See more details at: Template_talk:Precision. -Wikid77 (talk) 15:09, 17 November 2010 (UTC)

Expansion depth if rounding scientific notation

[вироиши манбаъ]

Some conversions, reaching into billions, are nearing the MediaWiki expansion depth limit, so in ranges, an amount of 2 billion exceeds the limit

  • {convert|2,000,000|km|m} → 2,000,000 километр (2.0×109 м)
  • {convert|20,000,000|km|m} → 20,000,000 километр (2.0×1010 м)
  • {convert|3,787,878.8|mi|ft} → 3,787,878.8 miles (2.0000000×1010 ft)
  • {convert|1000|-|2,000,000|km|m} → 1,000–2,000,000 километр (1,000,000–2.0000×109 м)
  • {convert|1000|-|3,787,878.8|mi|ft} → 1,000–3,787,878.8 miles (5,280,000–2.0000000×1010 ft)

Much of the nested expansion is occurring inside Template:rnd, which requires 17 expansion levels and cannot function when nested 24 levels deep, but works when 23 deep (of the 40-level limit):

: Nest 24 templates & {rnd|2000000400|-3}:
{{1x|{{1x|{{1x|{{1x|{{1x|{{1x|{{1x|{{1x|{{1x|{{1x
|{{1x|{{1x|{{1x|{{1x| {{1x|{{1x|{{1x|{{1x|{{1x|{{1x
|{{1x|{{1x|{{1x|{{1x
|{{rnd|2000000400|-3}}
}}}} }}}} }}}} }}}} }}}} }}}} }}}} }}}} }}}} }}}}
}}}} }}}}
Nest 24 templates & {rnd|2000000400|-3}: 0


Nest 23 templates & {rnd|2000000400|-3}: 0


However, the Template:Rndpad requires only 8 expansion levels to round billions, and it can round 2 billion (2,000,000,400) when nested even 32 levels deep, rather than only 22 levels:

Nest 32 templates & {rndpad|2000000400|-3}: 2000000000


Nest 33 templates & {rndpad|2355.07|1}: 2355.1


Nest 34 templates & {rnd|2355.07|1}: <span class="Pfunc_expr_unexpected_operator">Expression error: Unexpected < operator</span>

Because {rndpad} does not use scientific notation until over 85 billion, it can handle all ranges of millions, plus billions up through 84 billion, using only 7-8 expansion levels. -Wikid77 20:09, 16 January 2011 (UTC)