Template talk:Dimanalysis

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
WikiProject iconPhysics Template‑class
WikiProject iconThis template is within the scope of WikiProject Physics, a collaborative effort to improve the coverage of Physics on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
TemplateThis template does not require a rating on Wikipedia's content assessment scale.

Contested deletion[edit]

This page should not be speedily deleted because I am in the process of creating it into a real template - it is not intended to be a test. Please decline the deletion.

Actually you can speedily delete Dimanalysis (article) which was a mistake. Thanks. --Maschen (talk) 13:12, 21 September 2012 (UTC)[reply]

Default behaviour for omitted parameters[edit]

It would be really nice if parameters defaulted to 0 (specifically no output symbol) rather than 1. As it stands, one is forced to insert a parameter to remove it from the output, which means a lot of typing. As a secondary point: omitting a parameter should omit it from the output. But since there are times when an explicit zero power may be desired, this should be supported, probably by not omitting it when the template parameter is present and set to zero. — Quondum 23:26, 15 July 2013 (UTC)[reply]

Thanks for feedback. Will try and fix with the relevant Help:Magic words#Conditional expressions. M∧Ŝc2ħεИτlk 23:51, 15 July 2013 (UTC)[reply]
Done, possibly. Any better? M∧Ŝc2ħεИτlk 00:03, 16 July 2013 (UTC)[reply]
BTW, I really can't think of when an explicit zero power may be desired... Why should the template need this? M∧Ŝc2ħεИτlk 00:06, 16 July 2013 (UTC)[reply]
Yup, definitely better. What made me think of being able to put in an explicit zero exponent was that the Electronvolt article had one before I removed it – which means that some editors might like it as a matter of style. Where I thought it might actually make sense is in a table, where omitting the zero exponent would throw out the vertical alignment, making vertical comparisons more difficult. But the case for this is weak, so I wouldn't bother until the template has seen a lot more use and the need has been established. This kind of tunability seems to find its way into templates eventually. — Quondum 01:45, 16 July 2013 (UTC)[reply]

Reworked template[edit]

I've tried to clean up the template and its subtemplate:

  • I've removed the |brackets= parameter, since this conflicts with the ISQ convention of square brackets to mean "units of", and would thus be very confusing.
  • I've moved some logic into the subtemplate to reduce repetition, template size and complexity.
  • I've moved Template:Dimanalblock to Template:Dimanalysis/dim, since it really is only intended to be used by Template:Dimanalysis.
  • I've requested deletion of the redirect that was left behind.

There are still some outstanding issues that need addressing:

  1. The template should produce the symbol 1 when it is dimensionless (all exponents zero); currently it produces nothing, e.g. "{{dimanalysis|length=0}}" produces "1".  Done 10:19, 26 May 2015 (UTC)
  2. The |bold= option is contrary to the conventions of the ISQ and SI. Despite this, bolding is used in WP, for example in {{SI light units}} – see the associated discussion. I've added a caution against using bold in the documentation here, but we could go further.
  3. The parameter |mole= is named after a unit, not a quantity. Should we rename this to |amount= while there are few uses?  Done 03:24, 26 May 2015 (UTC)

Quondum 21:12, 24 May 2015 (UTC)[reply]

I've forced a sans-serif font for the symbols (but not the exponents); this might just force the default sans-serif font of the browser. A further issue: we should force a roman type. I know how to force italics (<i>...</i>), but I don't know how to force non-italics (i.e. roman). —Quondum 22:52, 25 May 2015 (UTC)[reply]

Done. Examples:
Standard font test: T−1L2MJ testing
Standard italic font test: T−1L2MJ testing
Serif font test: T−1L2MJ testing
Serif italic font test: T−1L2MJ testing
--Srleffler (talk) 01:35, 26 May 2015 (UTC)[reply]
Thank you. That takes care of that one. Now we're still left with the only numbered issues. —Quondum 03:24, 26 May 2015 (UTC)[reply]
About bold, as with square brackets they were included since I've seen them in places, once again feel free to remove. About all exponents zero to produce 1, maybe use a conditional expression like the last first and second in the table: {{#switch:string |c1=r1 |c2=r2 ... |default}} {{#if:string |result1 |result2}} and {{#ifeq:string1|string2 |result1 |result2}}, trying it now. M∧Ŝc2ħεИτlk 09:35, 26 May 2015 (UTC)[reply]
More testing:
  • some 1 some 0: TL
  • all 1: TLM
  • all 0: 1
  • all blank: 1
  • some 1 some 0: TL
  • all 1: TLM
  • all 0: 1
  • all blank: 1
M∧Ŝc2ħεИτlk 10:16, 26 May 2015 (UTC)[reply]
Neat. Seems to work well. Thanks —Quondum 14:18, 26 May 2015 (UTC)[reply]
One thing that was lost in today's edits is that the exponents are now forced to be in sans-serif font; that was not the case previously. Not a big deal, especially since Wikipedia's default font is sans-serif.--Srleffler (talk) 01:27, 27 May 2015 (UTC)[reply]
I thought about that before making the change. Imagine an italic serif text embedding the symbols. It seemed fair to me that the exponents should follow the font of the symbols, even embeded in another font (but not overwhelmingly so: it might look odd juxtaposed with a formula where the exponents are italic or serif). Italic serif exponents on the symbols did not seem to my mind's eye to be any better. The simpler encoding also played a part in my choice. Compare:
The dimensions of squirble are L2T−3Θ5 in the universe of Snarb.
The dimensions of squirble are L2T−3Θ5 in the universe of Snarb.
Quondum 02:33, 27 May 2015 (UTC)[reply]
I'm not sure about the removal of forcing, since the '1' is in essence a symbol too. But, like the exponents, this is a fuzzy issue, so probably doesn't matter hugely. —Quondum 12:42, 27 May 2015 (UTC)[reply]
That edit was to localize the font forcing - it failed to make much difference. If we didn't need the template to default to 1 when all parameters are empty, then it would work fine. Who will use the template with blank parameters anyway? It would be simpler to just type 1 instead of the template blank. I'm inclined to revert my recent edits to your version.
Otherwise, the template may as well be just scrapped altogether. The template needs considerable coding, and it takes quite a bit to type what's needed rather than using ordinary syntax... M∧Ŝc2ħεИτlk 22:06, 27 May 2015 (UTC)[reply]
Its major benefit is like that of {{val}}: it provides a standard formatting (ordering, font, etc.). For people like me: I might use it just to get it right. Where I want the font forced, it will be great. Even though entering it is more verbose than the symbols, using it serves to document (and allow subsequent wiki-wide tweaking of) the fact that there is a wiki standard. Also, what if its parameters are the output of templates? Or if it gets used in a larger template that passes its own parameters to it, parameters that are not known to that template's writers? So I would not advocate scrapping it, even if its use in articles remains limited. —Quondum 22:37, 27 May 2015 (UTC)[reply]
OK, but IMO we should still revert to your version since it worked better. M∧Ŝc2ħεИτlk 00:35, 29 May 2015 (UTC)[reply]
Except that it should still produce the '1' when there are no parameters, and mine didn't. My preference would be to simply revert your last revert. In what way did it work "better"? —Quondum 01:03, 29 May 2015 (UTC)[reply]
Worked better since the fonts were correct, as Srleffler says above. It may not be a problem on WP since the default font is sans serif, but it should still be coded properly to cope with any possible font changes the developers could make. Still, if people are happy with the current template then no more needs to be done. M∧Ŝc2ħεИτlk 11:39, 29 May 2015 (UTC)[reply]
I'm leaning towards removing formatting from anything but the six defined symbols, having now done some editing using these symbols. If I'm understanding the above discussion correctly (though I'm finding it difficult to follow), this means we are all in agreement on this. Hopefully my understanding is correct, so I'll make the change. —Quondum 15:50, 31 May 2015 (UTC)[reply]