Module talk:European and national party data/Archive 1: Difference between revisions

Content deleted Content added
remove page from Special:WantedTemplates
 
(25 intermediate revisions by 2 users not shown)
Line 1:
== Roadmap for EUPP seats module/template ==
== Project roadmap ==
 
Following the discussion [[Wikipedia_talk:Lua#Module calling Wikidata to list European parties' seats in various institutions|on the Lua talk page]], here is the roadmap for the template and module:
 
{| class="wikitable centre sortable"
Line 7 ⟶ 9:
!Comments
|-
| Create Template talk:SeatsEUPPs
| 1.1 Create the module "EU party seats lower upper houses" to give out the number of seats in lower/upper houses held by all the national member parties of a given European political party; the module should also give the associated composition bar
| style="text-align: center;" |✅
|
| See [[Module talk:EUPP seats/testcases|test cases]] and, for the sandbox, tests for the [[Module:EUPP seats/sandbox/testcases|main function]] and [[Module:EUPP seats/sandbox/testcases composition bar|composition bars]]
|-
| 1.2 IntegrateRedirect module abovetalk intopages EUPPto seatsTemplate moduletalk:SeatsEUPPs
| style="text-align: center;" |✅
|
| [[Module:EUPP seats]] is now the reference
|-
| Create [[Template:EUPP seats/sandbox]] so that it uses [[Module:EUPP seats/sandbox]]
| 1.3 Ensure comments are all in the code
| style="text-align: center;" |✅
|
|-
| Create [[Template:EUPP seats/testcases]]
| 1.4 Update documentation of EUPP seats module and its two templates
| style="text-align: center;" |✅
|
| [[Template:EUPP seats]], [[Template:EUPP composition bar]]
|-
| Replace documentation for Template:SeatsEUPPs
| 2.1 Update membership of European parties' national member parties based on APPF data
| style="text-align: center;" |✅
|
|-
| Create module testcases; see mw:Multilingual Templates and Modules#Testcases
| 2.2 Make a table of lower and upper houses and their qID for each EU member state
| style="text-align: center;" |✅
|
| [https://commons.wikimedia.org/wiki/Data:Lower_and_upper_houses_of_eu_member_states.tab Lower/upper houses per MS]
|-
| Make sure that at least one (probably both) of above testcases have a test for each of the error messages
| style="text-align: center;" |✅
| Done for Module:SeatsEUPPs/testcases
|-
| Improve description text above functions seats() and seats_share() in both the live and sandbox modules
| 2.3 Find qIDs of all national member parties and update [https://commons.wikimedia.org/wiki/Data:Seats_of_EU_national_parties_in_lower_and_upper_houses.tab Wikimedia Commons table]
| style="text-align: center;" |✅
|
|-
| Review all the comments in live and sandbox modules
| 2.4 Update Wikidata for seats in lower/upper houses for all relevant national member parties
| style="text-align: center;" |✅
|
|-
| Review all error messages in [[Module:EUPP seats/config]]
| 2.5 Update infoboxes of EUPPs on Wikipedia to use templates
| style="text-align: center;" |✅
|
|-
| Make separate validation function for width
| 3.1 Create the national_party_composition_bar function (in EUPP seats module) to give out a political party's composition bar in its relevant national lower or upper house (called from national party infobox, takes "lower house" or "upper house" as argument)
| style="text-align: center;" |⚠️
|
| Underway
|-
| Make separate validation function for institution and party
| 3.2 Create two templates related to the module above, one for the number, one for the composition bar, and add documentation
| style="text-align: center;" |
|
|-
| Fix issues with error messages in [[Module:EUPP seats/sandbox]]
| 3.3 Check/update the EUPP membership, country, and hex value of national parties on Wikidata
| style="text-align: center;" |
|
|-
| Update documentation
| 3.4 Update national member parties' infoboxes to use the above template (including a comment with the URL of the party's page on Wikidata to make updates easier)
| style="text-align: center;" |
| Ready (check after sandbox is moved to main module)
|
|-
| Make documentation for [[Template:EUPP composition bar]]
| style="text-align: center;" |✅
| Ready
|-
| Rename all module/template pages to names "EUPP seats" and "EUPP composition bar"
| style="text-align: center;" |✅
|
|-
| Make separate validation function for percentage/reference
| style="text-align: center;" |✅
| Not needed, but might help fix issue further down
|-
| Make [[Template:EUPP composition bar]] use [[Module:EUPP seats]] instead of [[Module:EUPP seats/sandbox]]
| style="text-align: center;" |✅
|
|-
| Allow "ref=yes" alongside "yes" for references, error message for all other (same with "pc=" percentage)
| style="text-align: center;" |✅
| Done as part of broader change
|-
| Allow different order to parameters 3, 4, and 5
| style="text-align: center;" |✅
| Done as part of broader change
|-
| Fix composition_bar calling "this party" from non-party page (show error but also attempts to make a composition bar)
| style="text-align: center;" |✅
|
|-
| Allow to bypass colour with special parameter
| style="text-align: center;" |✅
| Done as part of broader change
|-
| Deploy on relevant pages
| style="text-align: center;" |✅
|
|-
| Make cosmetic tweaks to code
| style="text-align: center;" |⚠️
| Still relevant? Should we care that [[Template:EUPP composition bar]] or [[Template:EUPP seats]] shows an error at the top?
|}
 
== DiscussionQuestions ==
 
Is there a way to made a testcases page for <code>ModuleEUPPs/sandbox</code> to test the impact of the proposed code?
:@[[User:Trappist the monk|Trappist the monk]], wanna have some more Lua, party-related fun? ;) [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 21:03, 29 March 2025 (UTC)
::Perhaps. The above isn't sufficiently clear to give me an understanding of what needs to be done. In our last venture there was a template that served as an armature upon which a module could be hung. That doesn't appear to be the case this go round.
::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 22:03, 29 March 2025 (UTC)
:::I see what you mean. Obviously only points 1 and 7 need some Lua, and I think I can do most of point 1 by myself. As for point 7, it's actually just a simplified version of the <code>EUPP seats</code> module, except we do not need to indicate the party (it should be always use the party from which page it is called -- except for testing purposes, of course, and in this case we can give the qID of a specific national party) and we just use <code>lower house</code> or <code>upper house</code> for the institution (and the table in point 6 will make the link between the party's country and the qID of the lower or upper house). The way I see it, it's mostly a trimmed-down version of our previous module. [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 07:46, 30 March 2025 (UTC)
::::Do these templates/module in point 7 have a name? Point 7 mention a table from point 6. Is the table in point 6 something that exists on commons ([[c:Data:Seats_of_EU_national_parties_in_lower_and_upper_houses.tab|Data:Seats_of_EU_national_parties_in_lower_and_upper_houses.tab]] or some other) or is the table something that is maintained in a lua ~/config module? Is such table necessary for the purposes of point 7?
::::
::::I futzed about and hacked [[Module:Sandbox/Trappist the monk/party]] which seems to be a way to get all of the (so far) required data. Using the [[NEOS]] qid ({{Q|Q13564543}}) for an example:
:::::<syntaxhighlight lang="wikitext" inline="1">{{#invoke:Sandbox/Trappist the monk/party|main|Q13564543}}</syntaxhighlight> →
::::The only thing that is obviously missing is a way to distinguish 'upper' from 'lower'.
::::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 16:56, 30 March 2025 (UTC)
:::::That's a really good point, @[[User:Trappist the monk|Trappist the monk]]. My idea, since I am already using a Wikimedia Commons table for the module in point 1, was to also use a similar table that would just have six columns: country name, country_qid, lower house name, lower house qid, upper house name, upper house qid. Admittedly, only the qid are relevant, but that would make the table more readable to humans. As you indicate, that could probably also be in a config file. I guess the commons table might make it easier to amend if need be, but these are hardly things that are likely to change often. Come to think about it, we could even do without an extra table, as that information could be extracted from the commons table created for the module of point 1, which already links the qid of a national party with the qids of its lower and upper houses. The only issue with this is if someone tries to use the module (or its subsequent template) for a national party that is not a member of a European party; then it would not be included in the table made for the module of point 1 and the module/template would not work. By contrast, assume the party has a Wikidata page, this would most likely tie it to a jurisdiction and then we could tie it to a lower/upper house via either the commons table or the config file.
:::::As for your code, that is really useful. The way that I see it, a normal call would be <code>invoke: nameofmodule | main | house=lower-house</code> or something similar. A qid would only be added for testing purposes and, in the absence of one, it would just take the one from the page in question (as when we used "thisparty" before). And then <code>invoke: nameofmodule | composition_bar | house=lower-house</code> would give the related composition bar. The related template would be "name of template | house=lower-house" and "name of template for composition bar | house=upper-house". [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 18:03, 30 March 2025 (UTC)
:::::Here is the table I had in mind for point 6: https://commons.wikimedia.org/wiki/Data:Lower_and_upper_houses_of_eu_member_states.tab [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 18:45, 30 March 2025 (UTC)
::::::In real life, are you a politician? You just spent a lot of words in saying relatively little. So let me ask specific questions:
:::::::If there is no wikidata mechanism to determine which house is upper and which house is lower, choose one of these:
:::::::#we require {{para|house|&lt;{{var|house name}}>}}
:::::::#:+ this method does not require a separate tabular data file
:::::::#:− we must error check against the house names that wikidata knows about
:::::::#we fetch upper/lower qids from [[c:Data:Seats_of_EU_national_parties_in_lower_and_upper_houses.tab|Data:Seats_of_EU_national_parties_in_lower_and_upper_houses.tab]]
:::::::#:+ if that table is required elsewhere, no need to error check
:::::::#:− if that commons .tab file is not required elsewhere, it now becomes required here
::::::It seems to me that these modules should not rely on multiple data sources if at all possible. So, if point 7 can be satisfied by fetching its data from wikidata and requiring {{para|house|&lt;{{var|house name}}>}}, that would be best.
::::::
::::::You assiduously avoided the {{tq|Do these templates/module in point 7 have a name?}} question. What is the answer to that question?
::::::
::::::You haven't actually said: for the composition bar, is it the number of party seats against the number of house seats?
::::::
::::::Is the table in point 6 complete? Are there countries that have only one house? How do we distinguish between a unicameral country and missing data?
::::::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 19:13, 30 March 2025 (UTC)
:::::::Argh! On the other hand... a commons table like [[c:Data:Seats_of_EU_national_parties_in_lower_and_upper_houses.tab|Data:Seats_of_EU_national_parties_in_lower_and_upper_houses.tab]] that holds {{em|all}} of the necessary data avoids the issue of inconsistency at wikidata. For example, {{Q|Q1261401}} doesn't have {{property|P462}} but instead has {{property|P465}}. No doubt there are other inconsistencies. Like {{Q|Q112677506}} which lists two hex colors... Which of those do we use?
:::::::
:::::::Given that, I'm thinking that I might change my position to: both the point 1 and point 7 modules shall require the commons tabular data file that shall hold verified qids for those items that should be held in wikidata: seats occupied, number of seats in the party, etc – the periodically changing stuff. House names, party color, etc, stuff that rarely changes can be held in the tabular data file so that wikidata inconsistencies are avoided.
:::::::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 19:49, 30 March 2025 (UTC)
::::::::Hmm, I am reluctant to put too much in tabular data file, specifically to avoid things changing that would then need to be updated in that table, and I keep all that information updated: what if a party changes its colour? what if the name of a house changes? What I want to keep in that table (and what I can keep updated) is what national parties belongs to which European party (and locally, I have an easy was to assign the lower/upper house and their qid based on the country in question).
::::::::As to having a way to determine which house is lower and which is upper, I am sure I understand what this is for. Say you have the template in the infobox of a party; you call that template saying "lower-house". From the page of the party, you derive the party's qid, from that qid you vlookup the table to find the qid of the lower house in the tabular data, then you can place a call to wikidata to get the number of seats of that party in the lower house, and to get the total number of seats of that house. I am actively avoiding needing to add arguments in order to make the template copy-pastable, and I am not sure we can directly derive the lower house and the upper house just from the wikidata page of a country (as some will directly list upper/house, while other will point to the name of the bicameral parliament, which in turn will point to both houses).
::::::::Inconsistencies? I will go through all relevant parties, as indicated in point 5 (had not thought of missing P465, but I can make sure they exist) for all relevant parties. Likewise, I made the table of upper/lower houses and made sure it is complete and accurate; where this is no upper house, the legislative is unicameral.
::::::::Names of the modules in point 7 and 8? I don't know. Module: "Seats of EU national parties", something to that affect? [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 20:52, 30 March 2025 (UTC)
{{od}}
There may be a way to distinguish upper from lower in wikidata if the descriptions can be more-or-less normalized. Here is a list taken from the [[c:Data:Lower and upper houses of eu member states.tab|point 6]] tabular data file. You can see that there is rather a large amount of variation amongst these descriptions – more of what I was saying about wikidata inconsistency. Of course these could all be normalized to some degree and then along comes Joe Editor who tweaks his country's description and the whole mess falls apart.
{{collapse top |title=description from wikidata}}
*{{Q|Q871363}}: lower house of the Austrian Parliament
*{{Q|Q557150}}: upper house of the Austrian Parliament
*{{Q|Q1347545}}: lower house of the federal parliament of Belgium
*{{Q|Q1355042}}: upper house of the Belgian federal parliament
*{{Q|Q639704}}: parliament of Bulgaria
*{{Q|Q371576}}: parliament
*{{Q|Q1112381}}: parliament of Cyprus
*{{Q|Q320265}}: lower chamber of the bicameral Parliament of the Czech Republic
*{{Q|Q389423}}: Upper House of the Parliament of the Czech Republic
*{{Q|Q209151}}: parliament of Denmark
*{{Q|Q217799}}: unicameral legislature of Estonia
*{{Q|Q643412}}: supreme legislature of Finland
*{{Q|Q193582}}: lower house of the French Parliament under the Fifth Republic
*{{Q|Q215987}}: upper house of the French Parliament
*{{Q|Q154797}}: legislature of Germany; parliament
*{{Q|Q146138}}: organ representing the German states since 1949
*{{Q|Q477089}}: legislative body of the Greek Republic
*{{Q|Q648716}}: parliament of Hungary
*{{Q|Q651981}}: lower house of the Oireachtas (Irish parliament)
*{{Q|Q1127591}}: upper house of the Oireachtas (Irish parliament)
*{{Q|Q841424}}: lower house of the Italian Parliament
*{{Q|Q633872}}: upper house of the Parliament of Italy
*{{Q|Q822919}}: parliament of Latvia
*{{Q|Q374152}}: unicameral parliament of Lithuania
*{{Q|Q517449}}: parliament of the Grand Duchy of Luxembourg
*{{Q|Q1817866}}: constitutional legislative body in Malta
*{{Q|Q233262}}: lower house of the Netherlands parliament
*{{Q|Q59486}}: upper house of the Kingdom of the Netherlands
*{{Q|Q98964}}: lower house of Polish parliament
*{{Q|Q98975}}: upper house of the Polish parliament
*{{Q|Q740564}}: legislative body of Portugal
*{{Q|Q320306}}: lower house of the Parliament of Romania
*{{Q|Q1466018}}: upper house of the Romanian Parliament
*{{Q|Q1139204}}: unicameral parliament of Slovakia
*{{Q|Q1568676}}: National Assembly of Slovenia
*{{Q|Q953810}}: upper house
*{{Q|Q539149}}: lower house of the Cortes Generales (legislative branch of Spain's national government)
*{{Q|Q855343}}: upper house of Spain's parliament, the Cortes Generales
*{{Q|Q272930}}: supreme legislative body of Sweden
{{collapse bottom}}
I have, I think noodled out how to get colors. Some parties list both {{property|P462}} and {{property|P465}} so when that occurs, I have elected to use the P465 triplet because that seems more 'precise'?
 
Note: "for the 'share' outputs, should the output have a '%' suffix?" -> I would say no, as my idea was to use this for charts that need a percentage value (as a number, not a string). [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 08:03, 25 March 2025 (UTC)
—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 00:59, 31 March 2025 (UTC)
:I've copied the tests from [[User:Julius Schwarz/sandbox]] into {{tlx|test case}} templates at [[Template:SeatsEUPPs/testcases]]. I have also changed {{tlx|SeatsEUPPs/sandbox}} to use [[Module:SeatsEUPPs/sandbox]]. From the ~/testcases results, you can see that the live template rarely agrees with Module:SeatsEUPPs/sandbox. At a glance, testing the live module against the live template in ~/testcases gives similar results. No doubt, the live template uses it parameters differently from the modules.
:
:To change the live template so that it uses the live module, copy the contents of the {{tld|SeatsEUPPs/sandbox}} to {{tlx|SeatsEUPPs}}. In {{tlx|SeatsEUPPs}}, change the invoke to <syntaxhighlight lang="wikitext" inline="1">{{#invoke:SeatsEUPPs|main}}</syntaxhighlight>. Save.
:
:Look at ~/testcases again. All tests should produce similar results; the flagged tests should be the result of different error message formatting.
:—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 16:14, 25 March 2025 (UTC)
::How would one go about adding that "%"? [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 22:18, 25 March 2025 (UTC)
:::With the concatenation operator: <code>..'%'</code>
:::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 23:39, 25 March 2025 (UTC)
 
== Use of template ==
:I would agree with your assessment, whenever P465 is there, that's the better choice. As I said, I will try and ensure that it is there wherever possible.
:As for the upper/lower house distinction from Wikidata, I am still unsure as to why you think you need this. Take [[Christian Social Union in Bavaria]], for instance. Currently, the infobox contains reads, for the Bundestag, currently, the infobox, for the Bundestag seats, reads as follows: <code><nowiki>{{composition bar|44|100|hex={{party color|Christian Social Union of Bavaria}}|border=silver}}</nowiki></code>. I am suggesting to replace this with <code><nowiki>{{Seats of EU national parties|house=lower-house}}</nowiki></code>. The template would grab the CSU's qID, look up its jurisdiction, and then, from the tabular data from point 6 or from the config file, would derive the qID of the Bundestag and give out the composition bar. I understand your point of limiting the use of multiple data sources, but as you point out Wikidata is not consistent in its descriptions. And, at any rate, we would still need the template to be told whether we need upper or lower house seats, so I am unsure why you are trying to grab that information from Wikidata when we have an easy way to get the house's qid easily. [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 07:13, 31 March 2025 (UTC)
::To limit the number of data sources. Since it is necessary to fetch total number of seats in a house and the numbers of seats occupied by the various parties from wikidata, it seems to me that we should fetch as much data as possible from wikidata rather than have two separate sources. Other editors are going to maintain the wikidata data but who will maintain the commons tabular data? You? What happens when you open your door, step out, and are suddenly flattened by a steamroller?
::
::Currently there are four sources of data for [[Module:Sandbox/Julius Schwarz/EU party seats lower upper houses]]: wikidata, the wide tab file, the narrow tab file, and ~/config. Are all four really required? Numbers of seat and the numbers of the various occupants will periodically change so wikidata is required. Do we really need both the wide and the narrow tab files? It seems that all of the data in the narrow tab file is or in a future incarnation will exist in the wide tab file, so if a tab file is required, only one will be needed. Because data for these modules will be sourced from wikidata and perhaps a tab file, ~/config should not hold anything more than whatever is required for i18n.
::
::Looking at what the point 1 module already does, tell me again what it is the the point 7 module will do differently?
::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 17:20, 31 March 2025 (UTC)
:In the meantime, I managed to make substantial progress on the module of point 1. I can now get the number of seats of European parties' member parties, both for an actual party and using "all" -- at least based on this small [https://commons.wikimedia.org/wiki/Data:Seats_of_EU_national_parties_in_lower_and_upper_houses.tab test table].
:However, the composition_bar function, which used to work when only grabbing the data from the test table, no longer works when trying to get the total number of seats of all lower houses (for instance) using [https://commons.wikimedia.org/wiki/Data:Lower_and_upper_houses_of_eu_member_states.tab the table made in point 6]. Somehow get_house_seats returns a string, but I cannot see why.
:Looking forward, I am '''not''' quite sure how to grab the qID of the relevant European party when the module is called with "this party" instead of a party name.
:Any ideas? [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 12:09, 31 March 2025 (UTC)
::The call to <code>sum_house_seats()</code> looked like this:
:::<syntaxhighlight lang="lua" inline="1">local sum_house_seats = sum_house_seats(frame, european_party_name, house_type);</syntaxhighlight>
::but the function definition looked like this:
:::<syntaxhighlight lang="lua" inline="1">local function sum_house_seats(frame, house_type)</syntaxhighlight>
::<code>house_type</code> was getting its value from <code>european_party_name</code> so the code to get <code>house_qid</code> was bypassed. The default state of <code>house_qid</code> was empty string. When given an empty-string qid, {{tlx|wikidata}} returns an empty string; you can't add an empty string to a number.
::
::The third entry in [[c:Data:Lower and upper houses of eu member states.tab]] does not have an upper house so the code at [[Module:Sandbox/Julius_Schwarz/EU_party_seats_lower_upper_houses#L-126--L-131|lines 126–131]] returns a <code>nil</code> value for <code>house_qid</code>. When given a <code>nil</code> qid, {{tld|wikidata}} returns an empty string; you can't add an empty string to a number.
::
::I changed that function so that any nil <code>house_qid</code> skips the call to {{tld|wikidata}} and the function returns the number zero.
::
::To get the qid for the current page:
:::<syntaxhighlight lang="lua" inline="1">local this_page_qid = mw.wikibase.getEntityIdForCurrentPage();</syntaxhighlight>
::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 17:20, 31 March 2025 (UTC)
:::Aaaaahhhhh, thanks, I had missed that. Made some changes and I must have forgotten to remove that argument. And thanks for the qID of the current page, I will try and add that tomorrow and then work on some test cases and validation. [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 20:11, 31 March 2025 (UTC)
:::Aaaand once again, made progress, even added support for "thisparty" which works when called from page of a European party, but I get an error in the [[Module talk:Sandbox/Julius Schwarz/EU party seats lower upper houses/testcases|test cases]] and I am not finding it... [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 14:16, 1 April 2025 (UTC)
::::Aaand I just broke it even further before having to stop working... [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 16:29, 1 April 2025 (UTC)
::::{{ec}}
::::You've changed the module (and this page) since I began writing this response.
::::
::::This is the first failure that I <s style="color:red">see</s> saw listed under {{slink|Module_talk:Sandbox/Julius_Schwarz/EU_party_seats_lower_upper_houses/testcases|test_main}}:
:::::<syntaxhighlight lang="wikitext" inline="1">{{#invoke:Sandbox/Julius Schwarz/EU party seats lower upper houses|main|ALL|lower-house}}</syntaxhighlight> → {{#invoke:Sandbox/Julius Schwarz/EU party seats lower upper houses|main|ALL|lower-house}}
::::Clearly, that <s style="color:red">works</s> worked (it returned 406). There are four of these tests that differ only in the casing of the <code>ALL</code>, <code>All</code>, <code>all</code> (2×). At the bottom of [[Module_talk:Sandbox/Julius_Schwarz/EU_party_seats_lower_upper_houses/testcases|~/testcases]] is the hidden category {{cl|Pages with too many expensive parser function calls}}. When the expensive error counter exceeds the limit (500), <code>get_party_seats()</code> returns this error message (a string) instead of a numeric value:
:::::<syntaxhighlight lang="wikitext" inline="1">Lua error in Module:Sandbox/Julius_Schwarz/EU_party_seats_lower_upper_ho at line 185: <strong class="error"><span class="scribunto-error mw-scribunto-error-449e5552">Lua error: too many expensive function calls.</span></strong></syntaxhighlight>
::::The simple fix then ought to be the removal of test cases that are substantially the same.
::::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 17:00, 1 April 2025 (UTC)
:::::Thanks and, indeed, it used to work. However, I removed a whole bunch of test cases (had not considered the load, and actually maybe we can remove the option to quiz all, that might just be too much when the table is complete). However, the error is still there, it would seem. The last thing I did was to introduce to that "error house name" to try and figure out where things broke, but did not find the solution. [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 21:02, 1 April 2025 (UTC)
::::::Preview [[Module_talk:Sandbox/Julius_Schwarz/EU_party_seats_lower_upper_houses/testcases|~/testcases]] with [[Special:Permalink/1283433280|this version of the module]]. The expensive parser function count no longer exceeds the limit (371/500).
::::::
::::::Are <code>ms-lower-house</code> and <code>ms-upper-house</code> accepted parameter values but <code>lower-house</code> and <code>upper-house</code> are not? You are not checking for those so the tests that set the 'house' parameter to either of those values fail with 'error house name'. If the test for <code>house_type</code> is supposed to be the same for both <code>main()</code> and <code>composition_bar()</code>, you should probably make that test a simple function.
::::::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 22:04, 1 April 2025 (UTC)
:::::::The idea was as follows: since the testing on whether the house type is lower or upper house is always done with "lower-house" or "upper-house", I would not touch them and instead just to rename house_type to, for instance, "lower-house" if "lower" or "ms-lower-house" was entered. This way all three values would be accepted. I am actually not sure I understand what does not work with the present code (just like I don't really get why it impact main and not composition_bar even though it's the same code in both), but I try and make this a separate function indeed. [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 06:23, 2 April 2025 (UTC)
::::::::Seems fixed. I guess the issue was not to have an "else". [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 07:53, 2 April 2025 (UTC)
:::::::::Important note, the module is now integrated into [[Module:EUPP seats/sandbox]], which is were further changes should be made.
:::::::::@[[User:Trappist the monk|Trappist the monk]], I will add missing comments in the code. Could you kindly have a look to see whether things are well done and/or whether anything can make the code more efficient? [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 12:12, 2 April 2025 (UTC)
::::::::::I have done some rewriting:
::::::::::*[[Module:Tabular data]] no longer used in favor of fetching data directly from <code>tab_data_t</code> and <code>ms_data_t</code>. Those sequences were previously used only as loop counters. See <code>get_house_seats()</code>, <code>get_national_party_seats()</code>, and <code>sum_national_party_seats()</code>.
::::::::::*to support direct access of data in <code>tab_data_t</code> and <code>ms_data_t</code>, I created a function <code>build_tab_data()</code> in [[Module:EUPP_seats/config]]. This function creates a sequence of associative arrays where the appropriate column name indexes the row's data field.
::::::::::*I deleted the function <code>table.find()</code>. Its functionality is replaced by <code>invert_party_qid_map()</code> in Module:EUPP_seats/config. This avoids repeatedly looping through <code>cfg.parties_t</code> looking for 'this whatever's qid'. See <code>validate_party_house_type()</code> and <code>sum_national_party_seats()</code>.
::::::::::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 20:03, 2 April 2025 (UTC)
:::::::::::Fantastic! I was really glad it worked, but I did have a hunch things could be done better :) Thank you! [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 20:17, 2 April 2025 (UTC)
 
@[[User:Trappist the monk|Trappist the monk]] as you can tell, I am rather new to modules. My idea was that, by creating the module, we would use it directly in relevant pages. But from your last comment about the way forward, I have a sense that we will keep using the template. Does this mean that we should rewrite the template to call the module? For instance, the revised template would be <code><nowiki>{{SeatsEUPPs|EP|EPP}}</nowiki></code> and this would actually call <code><nowiki>{{#invoke:SeatsEUPPs|main|EP|EPP}}</nowiki></code>? Is it just for writing convenience, then? [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 08:09, 25 March 2025 (UTC)
== Point 3 (ex-point 7) ==
:I have no problem with using module invokes in article text... But, not all editors are sufficiently technically minded to do that. The template hides the function call (<code>main</code>) from editors.
 
I see that the discussion on the second module got lost in the error corrections of the first module. Now that the first module is nearing completion (and is integrated in [[Module:EUPP seats/sandbox]]), I would be happy to re-open this discussion, @[[User:Trappist the monk|Trappist the monk]].
 
One of your last question (that I left unanswered) was what the second module (now point 3.1) would do differently from the first. Both actually have a different focus:
* the first module aims at being called from the page of a European political party and to sum the members on lower/upper houses of its national member parties; since the calculation is different from our previous [[Module:EUPP seats]], I thought of keeping both separate, but then I figured it might make more sense to merge them;
* the second module aims at being called from the page of a national political parties and just grab its number of seats on lower/upper houses from Wikidata (a bit what [[Module:EUPP seats]] initially did for European parties, but at the national level); to me the idea of this is to try and move as much data to Wikidata and to encourage anyone seeking to update data on Wikipedia to actually do so on Wikidata instead.
 
Is that clearer like this?
 
PS: I added a function in the roadmap -- sometimes it would be useful to override the total number of seats in the composition bar (for cases where we would want to give out the number of seats of sub-group of the house, instead of the whole house). [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 14:01, 2 April 2025 (UTC)
 
:Also, @[[User:Trappist the monk|Trappist the monk]] do you confirm that you wish to discontinue the use of the [https://commons.wikimedia.org/wiki/Data:Lower_and_upper_houses_of_eu_member_states.tab "narrow" tab file] and only extract data from the [https://commons.wikimedia.org/wiki/Data:Seats_of_EU_national_parties_in_lower_and_upper_houses.tab "wide" tab file]? I can see how this limits the number of files we use, but is that efficient? It's a genuine question. The narrow one makes it straightfoward to count the total number of seats on lower or upper houses (without counting anything twice). If there is a way to make it as efficient (or nearly) with one file, that is of course fine by me. And, indeed, it is likely that the information from the narrow one will be in the wide one -- this would not be the case if, for instance, a member state had none of its national parties that a is a member of a European party; it could happen, but in practice it doesn't. [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 07:40, 3 April 2025 (UTC)
::The narrow commons file is no longer required. I have added a function to [[Module:EUPP seats/config]], <code>extract_ms_data()</code>, that extracts the necessary data from the data extracted from the wide tab file. So long as the multiple copies of each <code>member_state</code> row in the wide tab are all the same, the data for <code>lower_house</code>, <code>lower_house_qid</code>, <code>upper_house</code>, and <code>upper_house_qid</code> in the new <code>ms_tab_t</code> sequence should be correct (the new function takes only the row of data from the first encounter of a member state). Some of those data are not currently used: <code>member_state</code>, <code>lower_house</code>, and <code>upper_house</code> could be excluded from the new <code>ms_tab_t</code> sequence.
::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 01:04, 4 April 2025 (UTC)
:::This last point means removing <code>member_state = row_t.member_state,</code> and the two other similar lines from <code>extract_ms_data</code> in the config file, right? [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 09:12, 4 April 2025 (UTC)
::::Or not. If there will be a need for those then you should leave them in; if not, delete of comment out.
::::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 13:58, 4 April 2025 (UTC)
:I will try and get started on this module tomorrow or the day after. [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 15:51, 6 April 2025 (UTC)
::@[[User:Trappist the monk|Trappist the monk]] I have done some work on the national_party_composition_bar function and it seems to be working (although test cases are tricky because it is always called from the page of a national party). Would you mind having a look and checking whether the code is sound? I have tried it successfully on [[The Ecologists]] and on a non-party page where, expectedly, it gives an error message. [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 19:48, 7 April 2025 (UTC)
:::Seems like there is some commonality between <code>composition_bar()</code> and <code>national_party_composition_bar()</code>. Perhaps parts of those function that can be shared ought to be shared as separate functions.
:::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 22:07, 7 April 2025 (UTC)
::::They are close and do related things, but they operate differently, as the first one applies to all institutions but only for the European parties/alliances listed in the config file, while the other only works for lower/upper houses (therefore a different validation mechanism) and for all parties listed in the wide table. It's close, but, given the differences, I do not know whether we truly gain from trying to force a unique function that would have to be implemented in different ways. Just my two cents as things stand and happy to be proven wrong :) [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 07:17, 8 April 2025 (UTC)
 
== Adding support for European political alliances ==
 
Hi @[[User:Trappist the monk|Trappist the monk]], I added European political alliances in the [[Module:EUPP seats/config|config file]]. However, I then made changes to the module (seemed like a quick fix) but, I must have forgotten something, because it broke the non-party calls (misc_parties_t and keywords_t). Basically, European political alliances should work just like European political parties but should not count in the sum of seats occupied by all European parties ('all') and therefore also not in the sum of seats occupied by no European party ('none'); but should be able to get their number of seats and derive a composition bar. [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 15:20, 3 April 2025 (UTC)
:Some of the problem was resolved by exporting <code>alliances_t</code> from [[Module:EUPP seats/config|~/config]]. I fixed most of the other glaring red error messages. One that I didn't fix was this from one of the testcases pages:
::<syntaxhighlight lang="wikitext" inline="1">{{#invoke:EUPP seats/sandbox|main|EP||%}}</syntaxhighlight> → {{#invoke:EUPP seats/sandbox|main|EP||%}}
:That used to work (produced the 'party is required for share' error message). I leave it to you to figure out what it is that you did to break it.
:—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 17:05, 3 April 2025 (UTC)
:
:The nice thing about [[Module:Arguments]] is that it automatically fetches arguments from the both the frame and the parent frame. Writing <syntaxhighlight lang="wikitext" inline="1">{{#invoke:SeatsEUPPs|main}}</syntaxhighlight> in the template will hand the parent frame parameters (from the template call in article wikitext) to the module. You can see this working in {{tlx|SeatsEUPPs/sandbox}}:
:Oh, and, I first made these changes to the live module; I should not have done that. I have reverted the changes in the live module and made them in the sandbox because that is what sandboxen are for.
::<syntaxhighlight lang="wikitext" inline="1">{{SeatsEUPPs/sandbox|EP|EPP}}</syntaxhighlight> → {{t|SeatsEUPPs/sandbox|EP|EPP}}
:—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 17:15, 3 April 2025 (UTC)
:—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 16:14, 25 March 2025 (UTC)
::Thanks @[[User:Trappist the monk|Trappist the monk]]; is it perhaps possible that I changed an "if ... else..." into an "if ... elseif ... elseif..." (where the double elseif was aimed at separating cfg.parties_t from cfg.alliances_t) but that, in doing so, the other cases (everything else caught by "else") was not accounted for? I am having a look [https://en.wikipedia.org/w/index.php?title=Module%3AEUPP_seats%2Fsandbox&diff=1283782080&oldid=1283593721 here] and am looking at line 160 (old version). [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 20:35, 3 April 2025 (UTC)
::Yeah, I have to admit that's neater this way. Thanks, it's all looking really clear. [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 21:35, 25 March 2025 (UTC)
:::Could well be. In the current live version, <code>args_t</code> ends up as <syntaxhighlight lang="lua" inline="1">{'property', nil, 'P1410'}</syntaxhighlight> which causes the call to expand {{tlx|wikidata}} to return an empty string. Perhaps the thing to do is to add this at [[Module:EUPP_seats/sandbox#L-154|line 154]]:
::::<syntaxhighlight lang="lua"> elseif not party then -- <party> missing
return make_error_msg (substitute (cfg.error_messages_t.party_req_share));
else -- <party> unknown
return make_error_msg (substitute (cfg.error_messages_t.inst_unknown_party, {institution, party}));
</syntaxhighlight>
:::Current [[Module:EUPP_seats/sandbox#L-161--L-164|lines 161–164]] go away as redundant.
:::
:::I gotta wonder: is that the correct error message? <code>single()</code> is called twice: from <code>seats()</code> (currently [[Module:EUPP_seats/sandbox#L-222|line 222]]) and from <code>seats_share()</code> (currently [[Module:EUPP_seats/sandbox#L-260|line 260]]). Certainly the {{color|#d33|...required for share}} bit is required for <code>seats_share()</code> but for <code>seats()</code>?
:::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 22:03, 3 April 2025 (UTC)
::::It would seem like the errors are just due to too many calls, maybe? I made a separate [[Module talk:EUPP seats/sandbox/testcases composition bar|testcase page]] just for composition bars and it all seems to work well. [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 08:19, 4 April 2025 (UTC)
:::::As for the error message, it is to cover calls like this one <code><nowiki>{{#invoke:EUPP seats/sandbox|main|EP||%}}</nowiki></code>. [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 08:27, 4 April 2025 (UTC)
::::::Really, just that? Then perhaps that error message should be moved to <code>seats_share()</code> right at the top; something like this:
:::::::<syntaxhighlight lang="lua"> if not party then -- party not specified, abandon with error message
return make_error_msg (substitute (cfg.error_messages_t.party_req_share));
end</syntaxhighlight>
::::::no point in doing all of the work in <code>seats_share()</code> only to have <code>single()</code> return an error message because a required element was missing.
::::::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 14:40, 4 April 2025 (UTC)
:::::At [[Module talk:EUPP seats/sandbox/testcases composition bar]], not a single test passes. I gotta wonder if there is sommat wrong with [[Module:UnitTests]]. If I tweak the first test so that the numbers match (which in itself suggests that [[Module:EUPP seats/sandbox]] isn't working correctly). Then if the two outputs match I should get 'same':
::::::<syntaxhighlight lang="wikitext" inline="1">{{#ifeq:{{#invoke:EUPP seats/sandbox|composition_bar|EP|ALDE}}|{{Composition bar|49|720|hex=#FFD700}}|same|not same}}</syntaxhighlight> → {{#ifeq:{{#invoke:EUPP seats/sandbox|composition_bar|EP|ALDE}}|{{Composition bar|49|720|hex=#FFD700}}|same|not same}}
:::::and I do. Something about Module:UnitTests is not working correctly. That still leaves questions about the testcases:
:::::*is Module:EUPP seats/sandbox working correctly when it produces numbers that are different from the expected numbers?
:::::*are the expected numbers correct?
:::::*what about the tests that show different colors? which is correct?
:::::As an experiment, I edited [[Module:EUPP seats/sandbox/testcases composition bar]] so that the first test expected and actual were the same:
::::::<syntaxhighlight lang="lua" inline="1">self:preprocess_equals('{{#invoke:EUPP seats/sandbox|composition_bar|EP|ALDE}}', '{{#invoke:EUPP seats/sandbox|composition_bar|EP|ALDE}}')</syntaxhighlight>
:::::Module:UnitTests still thinks that the test fails.
:::::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 14:40, 4 April 2025 (UTC)
::::::I made changes here and there to the test, varying the party, etc., without always warying the colour for instance, so there are normal discrepancies. However, even when the bars exactly match the result of the test is shown as negative, it's always been like this for me.
::::::More worryingly, though, all the composition bars are broken, even in the main module, the one that worked an hour ago (haven't touched it since). Check [[European Green Party]] for instance [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 14:52, 4 April 2025 (UTC)
::::::The error is always "Lua error in Module:EUPP_seats/config at line 151: table index is nil." [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 14:54, 4 April 2025 (UTC)
:::::::Why does the last row of [[c:Data:Seats of EU national parties in lower and upper houses.tab]] hold only 'null' values. Delete that row and I expect that [[European Green Party]] will stop showing the glaring red error messages. You did just edit that table, right?
:::::::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 15:15, 4 April 2025 (UTC)
::::::::You were right, that was the issues. Turns out it's something that is added when importing a csv file. Would it be possible for the function to account for that and to simply ignore a line that has no european_party? [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 18:41, 4 April 2025 (UTC)
::::::When testing the output of a template or module against the output of another template or module, you need to use <code>preprocess_equals_preprocess</code>. When that test is used, this test passes:
:::::::<syntaxhighlight lang="lua" inline="1">self:preprocess_equals_preprocess('{{#invoke:EUPP seats/sandbox|composition_bar|EP|ALDE}}', '{{#invoke:EUPP seats/sandbox|composition_bar|EP|ALDE}}')</syntaxhighlight>
::::::<code>preprocess_equals</code> fails because the test is comparing the preprocessed output of the #invoke against the plain wikitext of the expected template. This:
:::::::{{code|lang=html|{{#invoke:EUPP seats/sandbox|composition_bar|EP|ALDE}}}}
::::::does not equal this:
:::::::<syntaxhighlight lang="wikitext" inline="1">{{#invoke:EUPP seats/sandbox|composition_bar|EP|ALDE}}</syntaxhighlight>
::::::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 17:03, 4 April 2025 (UTC)
:::::::Just changed it, thanks! [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 17:53, 4 April 2025 (UTC)
 
== Continuation ==
== Error for two European parties ==
 
Hi @[[User:Trappist the monk|Trappist the monk]], before you bow out, allow me to ask one more thing. I started replacing raw calls to wikidata with the module and it hit me that, in most cases, this is being used as part of a composition bar. Not always, but super often.
As I add data to the wide table, I implement the "EUPP composition bar" template on the relevant pages of European parties, by adding <code><nowiki>{{EUPP composition bar|ms-upper-house|thisparty|width=80%|percent=yes}}</nowiki></code> in the infobox (see [[European Green Party]] for instance).
 
SoAnd farall of a sudden, it hasbecame beena verybit smooth.irresistible to make another Howevermodule, forbased theon [[PartyModule:SeatsEUPPs]] ofthat thewould Europeanspit Left]]out andthe [[Europeancomposition People'sbar Party]]:D Now, itI givesgot outthe "Luagist errorof inmost Module:EUPP_seatsof atthe lineprocess, 437:but attemptI tocould performuse arithmetica onquick ahand stringto value",write inthe bothpart casesthat justactually forwrites the uppercomposition house.bar Anyusing ideas?our Imodule. checkedWould theyou datamind andhaving ita seemslook? inIt's order.at [[Module:Sandbox/Julius Schwarz/CompositionBarEUPPs]] [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 1221:43, 425 AprilMarch 2025 (UTC)
:Forking is a bad idea. Instead, add a new exported function to [[Module:SeatsEUPPs/sandbox]] that calls the necessary local functions to produce the output that you want. I've started a function <code>composition_bar()</code> at the bottom of ~/sandbox, added some comments and questions there. Improve on that.
 
::<syntaxhighlight lang="wikitext" inline="1">{{#invoke:SeatsEUPPs/sandbox|composition_bar|EC|EPP}}</syntaxhighlight> → <nowiki>{{#invoke:SeatsEUPPs/sandbox|composition_bar|EC|EPP}}</nowiki>
:Ok, the other issue is fixed. Any clue about this, @[[User:Trappist the monk|Trappist the monk]]? [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 17:55, 4 April 2025 (UTC)
:—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 22:50, 25 March 2025 (UTC)
::I think that I have tracked it to {{Q|Q1315362}}. If I write these templates (takes [[Module:EUPP_seats/sandbox]] out of the loop) I get unexpected results for the upper house:
::Well noted. I started having a look at the comment you made. For line 346, indeed, share has no place here. That was in case "%" or "share" ended up as the party argument. Not happening here. And I will introduce data validation for width and percentage. However, I hit the same issue three times: 1) width should be a percentage and not a number should we can input it as a number but we have attach a "%" sign; 2) I have to attach a "#" sign to the hex code; and 3) I might attach a "%" for seats_share. In all three cases, I am not sure how to concatenate text. [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 23:57, 25 March 2025 (UTC)
:::lower house: <syntaxhighlight lang="wikitext" inline="1">{{wikidata|property|Q1315362|P1410|P194=Q320265}}</syntaxhighlight> → {{wikidata|property|Q1315362|P1410|P194=Q320265}} – a number so that's ok
:::According to the {{tlx|Composition bar}} documentation, width specified as without units assumes <code>px</code>. The documentation also says that the template will also accept <code>%</code> and <code>em</code> units. I've added a snippet of code to validate the width value. Should probably be a separate function. Also added '#' to the color.
:::upper house: <syntaxhighlight lang="wikitext" inline="1">{{wikidata|property|Q1315362|P1410|P194=Q389423}}</syntaxhighlight> → {{wikidata|property|Q1315362|P1410|P194=Q389423}} – (apparently empty string) not a number so not ok
:::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 00:45, 26 March 2025 (UTC)
::Q1315362 property {{property|P1410}} has 'issues' so perhaps fixing those will fix the problem.
::::Thanks and now indeed the colour displays properly. I did a similar operation to add "%" to the share_fc function, but reverted it as bar charts may need to do some calculation on the percentage, so better to leave it out until I create a separate function for this :) [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 08:05, 26 March 2025 (UTC)
::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 19:03, 4 April 2025 (UTC)
:::Yes, I also commented out and back in some entries::Thanks for the ESNhelp and identified@[[User:Trappist the AfD asmonk|Trappist the one responsiblemonk]]. ButI inthink thatwe case,are it'snearing because the entry was indeed emptycompletion. I fixed it and it works. Would there be a way to replace a missing entry with a zero but to record that somewhere? The issue here is thatupdated the Bundesratroadmap is filled by State-level coalitionsabove and theI coalitionthink seeminglywhen decidesthese together,items meaningare thedone seatsthis aren'tcan directlybe attributedconsidered tocompleted specific parties. So, onfor the onetime handbeing weand wouldI needwill tostart accountusing for the Bundesrat, butit on the other we can't directly link one seat to a party. It's easy for parties that are not in present at all in the coalitions (then it's 0), but not for therelevant restpages. [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 2011:4302, 427 AprilMarch 2025 (UTC)
::::::If {{tlx|CompositionBarEUPPs}} is going to mimic {{tlx|composition bar}}, it seems to me that {{tld|CompositionBarEUPPs}} should use the same parameter names for the options:
:::Turns out Levice was also just simply missing its upper house entry, but for no good reason. Currently, the reason above only affects the EPP (so my changes are pending), but that's because other German parties have 0 as a number of seats for the Bundesrat, but erroneously so. A proposal: we mute the error by replacing a missing value with 0, but we make a test function that would allow me to keep an eye on missing issue and that would report the parties with missing values. [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 20:51, 4 April 2025 (UTC)
::::::*{{para|background-color}}
::::Created <code><nowiki>{{#invoke:EUPP seats|test_wikidata_entries}}</nowiki></code> for this purpose. Seems to work.
::::::*{{para|border}}
::::Currently: <code><nowiki>{{#invoke:EUPP seats|test_wikidata_entries}}</nowiki></code> -> {{#invoke:EUPP seats|test_wikidata_entries}} [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 11:57, 6 April 2025 (UTC)
::::::*{{para|width}}
 
::::::*{{para|per}}
== Capitalisation ==
::::::*{{para|ref}}
 
::::::That means no <syntaxhighlight lang="wikitext" inline="1">{{{3}}}</syntaxhighlight>, <syntaxhighlight lang="wikitext" inline="1">{{{4}}}</syntaxhighlight>, <syntaxhighlight lang="wikitext" inline="1">{{{5}}}</syntaxhighlight>.
Since it may be that some party/alliance names are not capitalised in the table (and I do not want to force this), I wanted to make sure that, when we compare a requested European party (from the argument) with the entries of the first column, we compare to the capitalised version of the entries (because we force the capitalisation of the arguments.
 
I tried changing:
 
<code>if european_party == cfg.tab_data_t[row]['european_party'] then</code>
 
into:
 
<code>if european_party == cfg.tab_data_t[row]['european_party']:upper() then</code>
 
or
 
<code>if european_party == string.upper(cfg.tab_data_t[row]['european_party']) then</code>
 
but that did not work. Any idea why? [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 08:28, 6 April 2025 (UTC)
 
:I thought I had fixed it -- see latest changes to [[Module:EUPP seats/sandbox]], also deployed to [[Module:EUPP seats]]. And when I test both on my own sandbox ([[User:Julius Schwarz/sandbox]]), it works. But from [[Patriots.eu]], it doens't work. What am I missing, @[[User:Trappist the monk|Trappist the monk]]? [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 11:55, 6 April 2025 (UTC)
::Not obvious that [[Module:EUPP_seats#L-444--L-447|lines 444–447]] execute when the module is called from [[Patriots.eu]].
::
::Both of <syntaxhighlight lang="lua" inline="1">cfg.tab_data_t[row]['european_party']:upper()</syntaxhighlight> and <syntaxhighlight lang="lua" inline="1">string.upper(cfg.tab_data_t[row]['european_party']</syntaxhighlight> work to upcase the value assigned to <code>european_party</code>. But is that code necessary or appropriate? Oughtn't you to be checking that with <code>test_wikidata_entries()</code> rather than upcasing <code>cfg.tab_data_t[row]['european_party']</code> for every row in the loop?
::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 12:47, 6 April 2025 (UTC)
:::Not sure how test_wikidata_entries can help here -- it is just supposed to find issues in Wikidata itself. Here I just want the european_party under consideration to match the tabular data, whether the table has "PATRIOTS" or "Patriots" in the first column. Since the european_party is always capitalised, I was thinking of doing the if test with the capitalised version of the table cell value. And it does work well in the test (I added a non-capitalised version line at the bottom of the tabular data). [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 13:02, 6 April 2025 (UTC)
::::<code>test_wikidata_entries()</code> can ensure that all of the names listed under the <code>european_party</code> heading in the wide table are written using the correct case. That way you don't have to upcase <code>cfg.tab_data_t[row]['european_party']</code> every time you need that name. <code>test_wikidata_entries()</code> is really a cross-checking function; if there is an error in tested qids in the wide table, there is some chance that the function will catch that error. If you are going to establish a requirement that all parties named in the <code>european_party</code> column are uppercase, it makes sense to test those party names to ensure compliance with the requirement. The user should be able to write <code>patriots</code>, <code>PATRIOTS</code>, or anything in between; [[Module:EUPP seats]] will accommodate those variations because it only needs to do it once per template. That is better than doing it 265 times per template.
::::
::::{{tq|it does work well in the test}} but {{tq|from [[Patriots.eu]], it doens't work.}} What was {{tq|the test}}? How do you know that {{tq|from [[Patriots.eu]], it doens't work}}? These seem contradictory to me.
::::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 14:04, 6 April 2025 (UTC)
:::::But I am ''not'' establishing a requirement that all names in the first column be capitalised. Most are because they are acronyms, but others (Patriots, DiEM25, Volt, etc.) are not -- well, I capitalised them temporarily so that it would work, but that is just a temporary fix. We all people to call the module/templates with "Patriots" or "PaTrIoTs" and I think we should keep that fleibility in the table, because someone is bound not to respect the capitalisation, starting with me, since the initial table that I have should not have everything capitalised.
:::::As for the last question, when I call <code><nowiki>{{#invoke:EUPP seats|composition_bar|ms-lower-house|Patriots}}</nowiki></code> or <code><nowiki>{{EUPP composition bar|ms-lower-house|Patriots}}</nowiki></code> from my user sandbox, it works (it finds 734 seats (which accounts for the redundant last line of the table). However, when calling <code><nowiki>{{EUPP composition bar|ms-lower-house|thisparty}}</nowiki></code> from the page Patriots.eu, it gives 608 (which does not include the last line of the table, which is not capitalised. [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 14:30, 6 April 2025 (UTC)
::::::OR maybe we can force uppercase for the first column when we import the table via the config function? [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 14:55, 6 April 2025 (UTC)
::::::{{ec}}
::::::As you wish.
::::::
::::::To override the wikidata-supplied bar color we might reinstate <syntaxhighlight lang="wikitext" inline="1">{{{3}}}</syntaxhighlight> for use as {{tlx|composition bar}} uses it, or create a new option parameter {{para|bar-color}}. This latter would be my preference. Of course, I would also spell-out {{para|percent}} and {{para|reference}} (and also rename {{tld|CompositionBarEUPPs}} to {{tlx|Composition bar EUPPs}} or better, {{tlx|EUPP composition bar}} because English is written with space characters between words; I might even suggest {{tlx|EUPP seats}} as a better name).
::::::<syntaxhighlight lang="wikitext" inline="1">{{EUPP composition bar|ms-lower-house|Patriots}}</syntaxhighlight> doesn't 'work' because in [[Module:EUPP_seats#L-436--L-442|lines 436–442]], you do not do the upcasing thing.
::::::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 14:35, 27 March 2025 (UTC)
::::::
:::::::That seems all very sensible. For the colour element, I think it is nice to have it, but it should just be the exception; by default, we just take the registered party colour. And I am happy to rename the modules and templates. As for the arguments, like I wrote in the table, I was unfortunately stuck when I tried to use something else than 'yes' for percentage or reference, for instance. [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 14:58, 27 March 2025 (UTC)
::::::Alternate solution: Because we copy the tabular data file into a lua sequence, we can, as we read the data, upcase <code>european_party</code>. Add this at [[Module:EUPP_seats/config#L-123|line 123]]:
::::::::I've added a 'thisparty' test to <code>validate_institution_party()</code>. Seems to work, you might want to test it further.
:::::::<syntaxhighlight lang="lua" inline="1"> row_data_t.european_party = row_data_t.european_party:upper(); -- ensure <european_party> values are always uppercase</syntaxhighlight>
::::::::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 15:27, 27 March 2025 (UTC)
::::::Do nothing else; then look at [[Patriots.eu]].
::::::::
::::::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 14:59, 6 April 2025 (UTC)
::::::::Added support for {{para|width}} (<code>{{{3}}}</code>), {{para|pc}} (<code>{{{4}}}</code>), and {{para|ref}} (<code>{{{5}}}</code>). Still to do is to remove support for those positional parameters.
:::::::That's perfect! And I guess in the same way, we would skip an empty line (perhaps by just testing on whether the first column is empty, which it should never be)? [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 15:46, 6 April 2025 (UTC)
::::::::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 16:16, 27 March 2025 (UTC)
::::::::If {{tq|the first column is empty, which it should never be}}, I don't think you want to skip it. You should allow the module to shout an error (as it did when the whole bottom row was empty) because sommat is seriously wrong and needs urgent attention.
::::::::
::::::::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 16:02, 6 April 2025 (UTC)
::::::::Rewrote <code>get_colour()</code>. The hash prefix is added there because it should be possible to use named colors in {{para|bar-color}} (which overrides the wikidata color). Other color parameters also appear to be working:
:::::::::Yeah, that's a good point. Any recommendation for an entirely empty line? [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 16:44, 6 April 2025 (UTC)
:::::::::<syntaxhighlight lang="wikitext" inline="1">{{EUPP composition bar/sandbox|EC|EPP|bar-color=blue|border=red|background-color=#3a3}}</syntaxhighlight> → {{t|EUPP composition bar/sandbox|EC|EPP|bar-color=blue|border=red|background-color=#3a3}}
:::::::::I would like to avoid that crashing all the pages where the module is used.. [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 16:44, 6 April 2025 (UTC)
::::::::{{para|percent}} and {{para|ref}} are now case-insensitive. Positional parameters <code>{{{3}}}</code>, <code>{{{4}}}</code>, and <code>{{{5}}}</code> are now ignored.
::::::::::You could add a <code>null_row</code> export and then as part of <code>build_tab_data()</code>, test each row for all-nil values. If any whole row is nil, set <code>null_row</code> to some value – boolean <code>true</code>, the row number, an error message, etc. Then, in [[Module:EUPP seats]], look at <code>cfg.null_row</code>. If set do something about it.
::::::::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 00:31, 28 March 2025 (UTC)
::::::::::
:::::::::Thanks for this, @[[User:Trappist the monk|Trappist the monk]]; this is now all reflected in the testcases and it is all working correctly. I will therefore move the code to the main module and update the documentation accordingly. [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 09:08, 28 March 2025 (UTC)
::::::::::This idea not tested.
:In the module sandbox, I have streamlined <code>seats()</code> and <code>seats_share()</code>. [[Template:EUPP seats/testcases]] seems to show that I did not break anything. If you agree then the live module should be updated from the sandbox.
::::::::::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 18:00, 6 April 2025 (UTC)
:—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 15:42, 28 March 2025 (UTC)
 
::The changes are deployed and I confirm that nothing is broken! However, I started having a look at translation and it won't be as easy as planned since the Wikidata templates are not the same on all wikis. I think I can handle it, though. [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 15:52, 28 March 2025 (UTC)
== Error in mobile app ==
 
== Massive thanks! ==
@[[User:Trappist the monk|Trappist the monk]], in my browser, all the composition bars on the pages of European parties work. On the Android mobile app, however, several pages show error messages relating to the config file (for instance, Animal Politics EU and European Green Party, but not the European People's Party).
 
Just wanted to massively thank @[[User:Trappist the monk|Trappist the monk]] for their help on this. Given my own knowledge of Lua (or lack thereof), none of this would have been possible without them, and the code in the articles look much much neater now! I also learned a whole lot, which feels great. Admittedly, this does not impact too many pages per wiki, but it is directly applicable to many other wikis, so I look forward to working on translating it and replicating it! [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 14:38, 28 March 2025 (UTC)
[[File:Screenshot error module EUPP seats in Android mobile app.png|thumb|Screenshot error module EUPP seats in Android mobile app]] [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 07:47, 7 April 2025 (UTC)
:Caching problem? What happens if you purge the page? Does that android device have a browser option? Do the errors appear when viewed with the device's browser? That's about all the help that I can offer because I don't have an android device. I don't see the errors when viewing [[Animal Politics EU]] and [[European Green Party]] on my iphone.
:—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 11:31, 7 April 2025 (UTC)
::Thanks @[[User:Trappist the monk|Trappist the monk]]. I will check the cache and yes it does work from the browser of the same phone. On a separately topic, I note that the module does not work for European political alliances when called with "thisparty", I guess the check is only done on the party table. Unfortunately, I can't check this now, would it be possible for you to have a quick look? PS: data gathering on all national parties is now done and I am working on the "second module". [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 12:43, 7 April 2025 (UTC)
:::Link to someplace that doesn't work? What template specifically doesn't work?
:::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 12:55, 7 April 2025 (UTC)
::::Sorry, you can take [[European Pirate Party]] as an example. You will see in the infobox that figures for upper and lower houses are 0 -- this is not in line with the same calls (but using "PPEU" instead of "thisparty" on my own [[User:Julius Schwarz/sandbox|sandbox]]. Same for [[European Communist Action|ECA]] or [[Volt Europa|Volt]]. [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 14:23, 7 April 2025 (UTC)
:::::Maybe line 438; it seems like we try and find "thisparty" only in the list of parties, but not in the list of alliances. [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 14:30, 7 April 2025 (UTC)
::::::Dunno whether that was the best way, but I found a quick fix. [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 14:42, 7 April 2025 (UTC)
:::::::Thanks, I actually almost tried that but wasn't sure it'd work :) [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 14:58, 7 April 2025 (UTC)
:::::::{{ec}}
:::::::Simplified some. That code should work. Will <code>sum_national_party_seats()</code> ever be called without a party? If so, some sort of error trapping or default value will be needed.
:::::::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 15:02, 7 April 2025 (UTC)
::::::::It should not, no. Because it is only called internally, and it seems always after one of the two party validations functions are called. So if the party given in argument is not really a party, then there should be an error message before it reached that function. [[User:Julius Schwarz|Julius Schwarz]] ([[User talk:Julius Schwarz|talk]]) 18:44, 7 April 2025 (UTC)