User:Crunch41/sandbox: Difference between revisions
test |
An error in the weather box template for trace precipitation or rainfall in January |
||
(13 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
I came across an error message when trying to create a weather box. Any box with '''|Jan precipitation inch = trace''' will give an error. The same error also appears when '''|Jan rain inch = trace'''. Snowfall and metric units are not affected. A temporary fix can be made by changing the units for January to mm or cm. Since the value is only a trace, the change is not visible to the reader and does not change the yearly sum. |
|||
{{User sandbox}} |
|||
<!-- EDIT BELOW THIS LINE --> |
|||
The error traces back to the code for Module:Weather_box. Lines 203 and 214 |
|||
'''203:'''prefer_cm = precision(_ifset('Jan precipitation inch', '0')) < 1, |
|||
'''214:'''prefer_cm = precision(_ifset('Jan rain inch', '0')) < 1, |
|||
This box has Jan precipitation inch = trace |
|||
{{Weather box |
|||
|single line = Y |
|||
|Jan precipitation inch = trace |
|||
|Feb precipitation inch = 1.00 |
|||
|Mar precipitation inch = 1.00 |
|||
|Apr precipitation inch = 1.00 |
|||
|May precipitation inch = 1.00 |
|||
|Jun precipitation inch = 1.00 |
|||
|Jul precipitation inch = 1.00 |
|||
|Aug precipitation inch = 1.00 |
|||
|Sep precipitation inch = 1.00 |
|||
|Oct precipitation inch = 1.00 |
|||
|Nov precipitation inch = 1.00 |
|||
|Dec precipitation inch = 1.00 |
|||
}} |
|||
Any other month can be a trace, as long as January is not "trace". I tried a blank entry, a short text string "cat", and numbers. Deleting the row completely also does not cause an error. "trace" is the only value I found to cause an error. |
|||
{{Weather box |
|||
|single line = Y |
|||
|Jan precipitation inch = 0.00 |
|||
|Feb precipitation inch = trace |
|||
|Mar precipitation inch = trace |
|||
|Apr precipitation inch = trace |
|||
|May precipitation inch = trace |
|||
|Jun precipitation inch = trace |
|||
|Jul precipitation inch = trace |
|||
|Aug precipitation inch = trace |
|||
|Sep precipitation inch = trace |
|||
|Oct precipitation inch = trace |
|||
|Nov precipitation inch = trace |
|||
|Dec precipitation inch = trace |
|||
}} |
|||
This box has all months as a trace, but January has units of mm. This could be used as a workaround for the rare case it is needed. |
|||
{{Weather box |
|||
|single line = Y |
|||
|Jan precipitation mm = trace |
|||
|Feb precipitation inch = trace |
|||
|Mar precipitation inch = trace |
|||
|Apr precipitation inch = trace |
|||
|May precipitation inch = trace |
|||
|Jun precipitation inch = trace |
|||
|Jul precipitation inch = trace |
|||
|Aug precipitation inch = trace |
|||
|Sep precipitation inch = trace |
|||
|Oct precipitation inch = trace |
|||
|Nov precipitation inch = trace |
|||
|Dec precipitation inch = trace |
|||
}} |
|||
The same problem happens with Jan rain inch = trace. |
|||
{{Weather box |
|||
|single line = Y |
|||
|Jan rain inch = trace |
|||
|Feb rain inch = 1.00 |
|||
|Mar rain inch = 1.00 |
|||
|Apr rain inch = 1.00 |
|||
|May rain inch = 1.00 |
|||
|Jun rain inch = 1.00 |
|||
|Jul rain inch = 1.00 |
|||
|Aug rain inch = 1.00 |
|||
|Sep rain inch = 1.00 |
|||
|Oct rain inch = 1.00 |
|||
|Nov rain inch = 1.00 |
|||
|Dec rain inch = 1.00 |
|||
}} |
|||
Other months can have trace rainfall. |
|||
{{Weather box |
|||
|single line = Y |
|||
|Jan rain inch = 1.00 |
|||
|Feb rain inch = trace |
|||
|Mar rain inch = trace |
|||
|Apr rain inch = trace |
|||
|May rain inch = trace |
|||
|Jun rain inch = trace |
|||
|Jul rain inch = trace |
|||
|Aug rain inch = trace |
|||
|Sep rain inch = trace |
|||
|Oct rain inch = trace |
|||
|Nov rain inch = trace |
|||
|Dec rain inch = trace |
|||
}} |
|||
This does not happen with trace snowfall. |
|||
{{Weather box |
|||
|single line = Y |
|||
|Jan snow inch = trace |
|||
|Feb snow inch = 1.00 |
|||
|Mar snow inch = 1.00 |
|||
|Apr snow inch = 1.00 |
|||
|May snow inch = 1.00 |
|||
|Jun snow inch = 1.00 |
|||
|Jul snow inch = 1.00 |
|||
|Aug snow inch = 1.00 |
|||
|Sep snow inch = 1.00 |
|||
|Oct snow inch = 1.00 |
|||
|Nov snow inch = 1.00 |
|||
|Dec snow inch = 1.00 |
|||
}} |
|||
This also does not happen with metric units (mm or cm). |
|||
{{Weather box |
|||
|single line = Y |
|||
|metric first = Y |
|||
|Jan rain mm = trace |
|||
|Feb rain mm = trace |
|||
|Mar rain mm = trace |
|||
|Apr rain mm = trace |
|||
|May rain mm = trace |
|||
|Jun rain mm = trace |
|||
|Jul rain mm = trace |
|||
|Aug rain mm = trace |
|||
|Sep rain mm = trace |
|||
|Oct rain mm = trace |
|||
|Nov rain mm = trace |
|||
|Dec rain mm = trace |
|||
|Jan snow mm = trace |
|||
|Feb snow cm = trace |
|||
|Mar snow cm = trace |
|||
|Apr snow cm = trace |
|||
|May snow cm = trace |
|||
|Jun snow cm = trace |
|||
|Jul snow cm = trace |
|||
|Aug snow cm = trace |
|||
|Sep snow cm = trace |
|||
|Oct snow cm = trace |
|||
|Nov snow cm = trace |
|||
|Dec snow cm = trace |
|||
|Jan precipitation mm = trace |
|||
|Feb precipitation mm = trace |
|||
|Mar precipitation mm = trace |
|||
|Apr precipitation mm = trace |
|||
|May precipitation mm = trace |
|||
|Jun precipitation mm = trace |
|||
|Jul precipitation mm = trace |
|||
|Aug precipitation mm = trace |
|||
|Sep precipitation mm = trace |
|||
|Oct precipitation mm = trace |
|||
|Nov precipitation mm = trace |
|||
|Dec precipitation mm = trace |
|||
}} |
Latest revision as of 16:37, 5 February 2022
I came across an error message when trying to create a weather box. Any box with |Jan precipitation inch = trace will give an error. The same error also appears when |Jan rain inch = trace. Snowfall and metric units are not affected. A temporary fix can be made by changing the units for January to mm or cm. Since the value is only a trace, the change is not visible to the reader and does not change the yearly sum.
The error traces back to the code for Module:Weather_box. Lines 203 and 214
203:prefer_cm = precision(_ifset('Jan precipitation inch', '0')) < 1,
214:prefer_cm = precision(_ifset('Jan rain inch', '0')) < 1,
This box has Jan precipitation inch = trace
Climate data for {{{location}}} | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Month | Jan | Feb | Mar | Apr | May | Jun | Jul | Aug | Sep | Oct | Nov | Dec | Year |
Average precipitation inches (cm) | trace | 1.00 (2.5) |
1.00 (2.5) |
1.00 (2.5) |
1.00 (2.5) |
1.00 (2.5) |
1.00 (2.5) |
1.00 (2.5) |
1.00 (2.5) |
1.00 (2.5) |
1.00 (2.5) |
1.00 (2.5) |
11 (27.5) |
[citation needed] |
Any other month can be a trace, as long as January is not "trace". I tried a blank entry, a short text string "cat", and numbers. Deleting the row completely also does not cause an error. "trace" is the only value I found to cause an error.
Climate data for {{{location}}} | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Month | Jan | Feb | Mar | Apr | May | Jun | Jul | Aug | Sep | Oct | Nov | Dec | Year |
Average precipitation inches (mm) | 0.00 (0.00) |
trace | trace | trace | trace | trace | trace | trace | trace | trace | trace | trace | 0 (0) |
[citation needed] |
This box has all months as a trace, but January has units of mm. This could be used as a workaround for the rare case it is needed.
Climate data for {{{location}}} | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Month | Jan | Feb | Mar | Apr | May | Jun | Jul | Aug | Sep | Oct | Nov | Dec | Year |
Average precipitation inches (mm) | trace | trace | trace | trace | trace | trace | trace | trace | trace | trace | trace | trace | 0 (0) |
[citation needed] |
The same problem happens with Jan rain inch = trace.
Climate data for {{{location}}} | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Month | Jan | Feb | Mar | Apr | May | Jun | Jul | Aug | Sep | Oct | Nov | Dec | Year |
Average rainfall inches (cm) | trace | 1.00 (2.5) |
1.00 (2.5) |
1.00 (2.5) |
1.00 (2.5) |
1.00 (2.5) |
1.00 (2.5) |
1.00 (2.5) |
1.00 (2.5) |
1.00 (2.5) |
1.00 (2.5) |
1.00 (2.5) |
11 (27.5) |
[citation needed] |
Other months can have trace rainfall.
Climate data for {{{location}}} | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Month | Jan | Feb | Mar | Apr | May | Jun | Jul | Aug | Sep | Oct | Nov | Dec | Year |
Average rainfall inches (mm) | 1.00 (25) |
trace | trace | trace | trace | trace | trace | trace | trace | trace | trace | trace | 1 (25) |
[citation needed] |
This does not happen with trace snowfall.
Climate data for {{{location}}} | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Month | Jan | Feb | Mar | Apr | May | Jun | Jul | Aug | Sep | Oct | Nov | Dec | Year |
Average snowfall inches (cm) | trace | 1.00 (2.5) |
1.00 (2.5) |
1.00 (2.5) |
1.00 (2.5) |
1.00 (2.5) |
1.00 (2.5) |
1.00 (2.5) |
1.00 (2.5) |
1.00 (2.5) |
1.00 (2.5) |
1.00 (2.5) |
11 (27.5) |
[citation needed] |
This also does not happen with metric units (mm or cm).
Climate data for {{{location}}} | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Month | Jan | Feb | Mar | Apr | May | Jun | Jul | Aug | Sep | Oct | Nov | Dec | Year |
Average precipitation mm (inches) | trace | trace | trace | trace | trace | trace | trace | trace | trace | trace | trace | trace | 0 (0) |
Average rainfall mm (inches) | trace | trace | trace | trace | trace | trace | trace | trace | trace | trace | trace | trace | 0 (0) |
Average snowfall cm (inches) | trace | trace | trace | trace | trace | trace | trace | trace | trace | trace | trace | trace | 0 (0) |
[citation needed] |