sapor 0.3.0 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sapor/regional_data/european_union_27_italy.rb +3 -2
- data/lib/sapor/regional_data/european_union_italy.rb +3 -2
- data/lib/sapor/regional_data/european_union_luxembourg.rb +5 -5
- data/lib/sapor/regional_data/wallonia-20190526.psv +88 -0
- data/lib/sapor/regional_data/wallonia.rb +37 -22
- data/sapor.gemspec +1 -1
- data/spec/unit/european_union_luxembourg_spec.rb +2 -2
- data/spec/unit/wallonia_spec.rb +19 -79
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f37ce8d35c3bf87a4504f0eb4f000f288e691009fe91bb2ed4886de92fcdac8e
|
4
|
+
data.tar.gz: d8f11473d8554ca16948079f5c902bee7b61206f6fd51b83ecdca1354863329b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80c164dc69d557c13159444e7cbd0f435618020fb4a987a634beec653290e812c753ab0d849c78a86f506dcd37092f0dd80df2d99a73772901688efe349c278b
|
7
|
+
data.tar.gz: 5126c1dc5158a0c1a30c1b4d1196ebc3e10afe90bc61abcec1a46fb6f404a1e4050b96066a1dede4dd346fc58a0acf2cce1bed3d6cacde25dde248b0b94d44dc
|
@@ -49,7 +49,9 @@ module Sapor
|
|
49
49
|
|
50
50
|
private
|
51
51
|
|
52
|
-
COALITIONS = [['
|
52
|
+
COALITIONS = [['Azione (S&D)', 'Liberi e Uguali (S&D)',
|
53
|
+
'Partito Democratico (S&D)'],
|
54
|
+
['Cambiamo! (*)', 'Insieme (*)'],
|
53
55
|
['CasaPound Italia (NI)', 'Movimento 5 Stelle (NI)'],
|
54
56
|
['Civica Popolare (RE)', 'Italia Viva (RE)',
|
55
57
|
'Più Europa (RE)'],
|
@@ -57,7 +59,6 @@ module Sapor
|
|
57
59
|
['Forza Italia (EPP)', 'Südtiroler Volkspartei (EPP)'],
|
58
60
|
['Fratelli d’Italia (ECR)', 'Noi con l’Italia (ECR)'],
|
59
61
|
['Lega Nord (ID)'],
|
60
|
-
['Liberi e Uguali (S&D)', 'Partito Democratico (S&D)'],
|
61
62
|
['Potere al Popolo (GUE/NGL)']].freeze
|
62
63
|
|
63
64
|
NO_OF_SEATS = 76
|
@@ -49,7 +49,9 @@ module Sapor
|
|
49
49
|
|
50
50
|
private
|
51
51
|
|
52
|
-
COALITIONS = [['
|
52
|
+
COALITIONS = [['Azione (S&D)', 'Liberi e Uguali (S&D)',
|
53
|
+
'Partito Democratico (S&D)'],
|
54
|
+
['Cambiamo! (*)', 'Insieme (*)'],
|
53
55
|
['CasaPound Italia (NI)', 'Movimento 5 Stelle (NI)'],
|
54
56
|
['Civica Popolare (RE)', 'Italia Viva (RE)',
|
55
57
|
'Più Europa (RE)'],
|
@@ -57,7 +59,6 @@ module Sapor
|
|
57
59
|
['Forza Italia (EPP)', 'Südtiroler Volkspartei (EPP)'],
|
58
60
|
['Fratelli d’Italia (ECR)', 'Noi con l’Italia (ECR)'],
|
59
61
|
['Lega Nord (ID)'],
|
60
|
-
['Liberi e Uguali (S&D)', 'Partito Democratico (S&D)'],
|
61
62
|
['Potere al Popolo (GUE/NGL)']].freeze
|
62
63
|
|
63
64
|
NO_OF_SEATS = 73
|
@@ -58,11 +58,11 @@ module Sapor
|
|
58
58
|
|
59
59
|
NO_OF_SEATS = 6
|
60
60
|
|
61
|
-
# Voter turnout on
|
62
|
-
# Source: Web page with the official results of the elections of
|
63
|
-
#
|
64
|
-
# https://
|
65
|
-
POPULATION_SIZE =
|
61
|
+
# Voter turnout on 26 May 2019
|
62
|
+
# Source: Web page with the official results of the elections of 26 May
|
63
|
+
# 2019, downloaded on 18 December 2019,
|
64
|
+
# https://lb.wikipedia.org/wiki/Wale_fir_d%27Europ%C3%A4escht_Parlament_2019_(L%C3%ABtzebuerg)
|
65
|
+
POPULATION_SIZE = 1_254_363
|
66
66
|
|
67
67
|
def electoral_system
|
68
68
|
if @electoral_system.nil?
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# Statistical Analysis of Polling Results (SAPoR)
|
2
|
+
# Copyright (C) 2016 Filip van Laenen <f.a.vanlaenen@ieee.org>
|
3
|
+
#
|
4
|
+
# This file is part of SAPoR.
|
5
|
+
#
|
6
|
+
# SAPoR is free software: you can redistribute it and/or modify it under the
|
7
|
+
# terms of the GNU General Public License as published by the Free Software
|
8
|
+
# Foundation, either version 3 of the License, or (at your option) any later
|
9
|
+
# version.
|
10
|
+
#
|
11
|
+
# SAPoR is distributed in the hope that it will be useful, but WITHOUT ANY
|
12
|
+
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
13
|
+
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You can find a copy of the GNU General Public License in /doc/gpl.txt
|
16
|
+
#
|
17
|
+
|
18
|
+
# Source: Web page with the official results of the elections of 26 May 2019,
|
19
|
+
# downloaded on 23 November 2019,
|
20
|
+
# URL: https://verkiezingen2019.belgium.be/nl/verkiezingen?el=WL
|
21
|
+
|
22
|
+
Brabant wallon | Mouvement Réformateur | 81,684
|
23
|
+
Brabant wallon | Ecolo | 47,410
|
24
|
+
Brabant wallon | Parti Socialiste | 35,803
|
25
|
+
Brabant wallon | Centre démocrate humaniste | 20,216
|
26
|
+
Brabant wallon | Parti du Travail de Belgique | 18,074
|
27
|
+
Brabant wallon | DéFI | 15,196
|
28
|
+
Brabant wallon | Parti Populaire | 6,547
|
29
|
+
Brabant wallon | Listes Destexhe | 6,031
|
30
|
+
Brabant wallon | DierAnimal | 3,675
|
31
|
+
Brabant wallon | Collectif Citoyen | 2,818
|
32
|
+
Brabant wallon | Wallonie Insoumise | 1,892
|
33
|
+
Brabant wallon | Turquoise | 590
|
34
|
+
|
35
|
+
Hainaut | Parti Socialiste | 239,616
|
36
|
+
Hainaut | Mouvement Réformateur | 122,336
|
37
|
+
Hainaut | Parti du Travail de Belgique | 115,073
|
38
|
+
Hainaut | Ecolo | 83,938
|
39
|
+
Hainaut | Centre démocrate humaniste | 63,296
|
40
|
+
Hainaut | DéFI | 26,907
|
41
|
+
Hainaut | Parti Populaire | 27,361
|
42
|
+
Hainaut | Collectif Citoyen | 10,545
|
43
|
+
Hainaut | Listes Destexhe | 8,900
|
44
|
+
Hainaut | DierAnimal | 6,347
|
45
|
+
Hainaut | AGIR | 5,967
|
46
|
+
Hainaut | NATION | 4,759
|
47
|
+
Hainaut | La Droite | 3,407
|
48
|
+
Hainaut | Demain | 1,659
|
49
|
+
Hainaut | Parti Communiste de Belgique | 944
|
50
|
+
|
51
|
+
Liège | Parti Socialiste | 154,893
|
52
|
+
Liège | Mouvement Réformateur | 124,103
|
53
|
+
Liège | Ecolo | 93,921
|
54
|
+
Liège | Parti du Travail de Belgique | 93,293
|
55
|
+
Liège | Centre démocrate humaniste | 56,816
|
56
|
+
Liège | Parti Populaire | 26,047
|
57
|
+
Liège | DéFI | 23,144
|
58
|
+
Liège | Listes Destexhe | 9,955
|
59
|
+
Liège | Collectif Citoyen | 8,786
|
60
|
+
Liège | Wallonie Insoumise | 6,263
|
61
|
+
Liège | DierAnimal | 5,393
|
62
|
+
Liège | Demain | 2,784
|
63
|
+
Liège | NATION | 2,070
|
64
|
+
Liège | REFERENDUM | 621
|
65
|
+
|
66
|
+
Luxembourg | Mouvement Réformateur | 41,705
|
67
|
+
Luxembourg | Centre démocrate humaniste | 37,151
|
68
|
+
Luxembourg | Parti Socialiste | 32,317
|
69
|
+
Luxembourg | Ecolo | 24,323
|
70
|
+
Luxembourg | Parti du Travail de Belgique | 14,933
|
71
|
+
Luxembourg | Parti Populaire | 5,044
|
72
|
+
Luxembourg | DéFI | 4,786
|
73
|
+
Luxembourg | Collectif Citoyen | 2,070
|
74
|
+
Luxembourg | Listes Destexhe | 1,549
|
75
|
+
Luxembourg | NATION | 1,170
|
76
|
+
|
77
|
+
Namur | Parti Socialiste | 69,793
|
78
|
+
Namur | Mouvement Réformateur | 66,050
|
79
|
+
Namur | Centre démocrate humaniste | 46,296
|
80
|
+
Namur | Ecolo | 45,039
|
81
|
+
Namur | Parti du Travail de Belgique | 36,970
|
82
|
+
Namur | DéFI | 14,186
|
83
|
+
Namur | Parti Populaire | 9,623
|
84
|
+
Namur | Listes Destexhe | 4,443
|
85
|
+
Namur | DierAnimal | 3,002
|
86
|
+
Namur | Collectif Citoyen | 2,454
|
87
|
+
Namur | NATION | 1,650
|
88
|
+
Namur | AGIR | 1,179
|
@@ -27,29 +27,44 @@ module Sapor
|
|
27
27
|
'BE-WAL'
|
28
28
|
end
|
29
29
|
|
30
|
+
CDH_PARTY = 'Centre démocrate humaniste'.freeze
|
31
|
+
ECOLO_PARTY = 'Ecolo'.freeze
|
32
|
+
MR_PARTY = 'Mouvement Réformateur'.freeze
|
33
|
+
PS_PARTY = 'Parti Socialiste'.freeze
|
34
|
+
PTB_PARTY = 'Parti du Travail de Belgique'.freeze
|
35
|
+
|
30
36
|
def coalitions
|
31
|
-
[
|
32
|
-
|
33
|
-
|
37
|
+
[[CDH_PARTY, ECOLO_PARTY, MR_PARTY],
|
38
|
+
[CDH_PARTY, ECOLO_PARTY, PS_PARTY],
|
39
|
+
[CDH_PARTY, MR_PARTY],
|
40
|
+
[CDH_PARTY, PS_PARTY],
|
41
|
+
[CDH_PARTY, PS_PARTY, PTB_PARTY],
|
42
|
+
[ECOLO_PARTY, MR_PARTY],
|
43
|
+
[ECOLO_PARTY, MR_PARTY, PS_PARTY],
|
44
|
+
[ECOLO_PARTY, PS_PARTY],
|
45
|
+
[ECOLO_PARTY, PS_PARTY, PTB_PARTY],
|
46
|
+
[ECOLO_PARTY, PTB_PARTY],
|
47
|
+
[MR_PARTY, PS_PARTY],
|
48
|
+
[PS_PARTY, PTB_PARTY]]
|
34
49
|
end
|
35
50
|
|
36
51
|
def no_of_seats
|
37
52
|
SEAT_DISTRIBUTION.values.inject(:+)
|
38
53
|
end
|
39
54
|
|
40
|
-
def
|
41
|
-
if @
|
42
|
-
@
|
43
|
-
summarize_election_results(
|
55
|
+
def overall_election_results_of_2019
|
56
|
+
if @overall_election_results_of_2019.nil?
|
57
|
+
@overall_election_results_of_2019 = \
|
58
|
+
summarize_election_results(election_results_of_2019)
|
44
59
|
end
|
45
|
-
@
|
60
|
+
@overall_election_results_of_2019
|
46
61
|
end
|
47
62
|
|
48
63
|
def population_size
|
49
|
-
# Voter turnout on
|
50
|
-
# Source:
|
51
|
-
# Retrieved on
|
52
|
-
|
64
|
+
# Voter turnout on 26 May 2019
|
65
|
+
# Source: https://verkiezingen2019.belgium.be/nl/verkiezingen?el=WL
|
66
|
+
# Retrieved on 7 December 2019
|
67
|
+
2_034_813
|
53
68
|
end
|
54
69
|
|
55
70
|
def seats(simulation)
|
@@ -64,28 +79,28 @@ module Sapor
|
|
64
79
|
|
65
80
|
# Source: https://nl.wikipedia.org/wiki/Waals_Parlement
|
66
81
|
# Retrieved on 21 July 2017
|
67
|
-
SEAT_DISTRIBUTION = { 'Brabant
|
68
|
-
'Hainaut' =>
|
82
|
+
SEAT_DISTRIBUTION = { 'Brabant wallon' => 8,
|
83
|
+
'Hainaut' => 27,
|
69
84
|
'Liège' => 23,
|
70
|
-
'Luxembourg' =>
|
85
|
+
'Luxembourg' => 6,
|
71
86
|
'Namur' => 11 }.freeze
|
72
87
|
|
73
88
|
THRESHOLD = 0.05
|
74
89
|
|
75
|
-
def
|
76
|
-
if @
|
77
|
-
@
|
78
|
-
'wallonia-
|
90
|
+
def election_results_of_2019
|
91
|
+
if @election_results_of_2019.nil?
|
92
|
+
@election_results_of_2019 = load_election_results( \
|
93
|
+
'wallonia-20190526.psv'
|
79
94
|
)
|
80
95
|
end
|
81
|
-
@
|
96
|
+
@election_results_of_2019
|
82
97
|
end
|
83
98
|
|
84
99
|
def electoral_system
|
85
100
|
if @electoral_system.nil?
|
86
101
|
@electoral_system = MultiDistrictProportional.new( \
|
87
|
-
|
88
|
-
|
102
|
+
overall_election_results_of_2019,
|
103
|
+
election_results_of_2019,
|
89
104
|
SEAT_DISTRIBUTION,
|
90
105
|
DhondtDenominators,
|
91
106
|
THRESHOLD
|
data/sapor.gemspec
CHANGED
@@ -32,9 +32,9 @@ describe Sapor::EuropeanUnionLuxembourg, '#no_of_seats' do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
describe Sapor::EuropeanUnionLuxembourg, '#population_size' do
|
35
|
-
it 'returns a population size of 1,
|
35
|
+
it 'returns a population size of 1,254,363' do
|
36
36
|
expect(Sapor::EuropeanUnionLuxembourg.instance.population_size).to \
|
37
|
-
eq(
|
37
|
+
eq(1_254_363)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
data/spec/unit/wallonia_spec.rb
CHANGED
@@ -25,52 +25,6 @@ describe Sapor::Wallonia, '#area_code' do
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
describe Sapor::Wallonia, '#coalitions' do
|
29
|
-
def walloon_coalitions
|
30
|
-
Sapor::Wallonia.instance.coalitions
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'returns MR + cdH + Ecolo as a coalition to track' do
|
34
|
-
expect(walloon_coalitions).to include(['cdH', 'Ecolo', 'MR'])
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'returns PS + cdH + Ecolo as a coalition to track' do
|
38
|
-
expect(walloon_coalitions).to include(['cdH', 'Ecolo', 'PS'])
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'returns MR + cdH as a coalition to track' do
|
42
|
-
expect(walloon_coalitions).to include(['cdH', 'MR'])
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'returns PS + cdH as a coalition to track' do
|
46
|
-
expect(walloon_coalitions).to include(['cdH', 'PS'])
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'returns PS + cdH + PTB as a coalition to track' do
|
50
|
-
expect(walloon_coalitions).to include(['cdH', 'PS', 'PTB'])
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'returns MR + Ecolo as a coalition to track' do
|
54
|
-
expect(walloon_coalitions).to include(['Ecolo', 'MR'])
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'returns PS + MR + Ecolo as a coalition to track' do
|
58
|
-
expect(walloon_coalitions).to include(['Ecolo', 'MR', 'PS'])
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'returns PS + Ecolo + PTB as a coalition to track' do
|
62
|
-
expect(walloon_coalitions).to include(['Ecolo', 'PS', 'PTB'])
|
63
|
-
end
|
64
|
-
|
65
|
-
it 'returns PS + MR as a coalition to track' do
|
66
|
-
expect(walloon_coalitions).to include(['MR', 'PS'])
|
67
|
-
end
|
68
|
-
|
69
|
-
it 'returns PS + PTB as a coalition to track' do
|
70
|
-
expect(walloon_coalitions).to include(['PS', 'PTB'])
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
28
|
describe Sapor::Wallonia, '#no_of_seats' do
|
75
29
|
it 'returns 75 as the number of seats' do
|
76
30
|
expect(Sapor::Wallonia.instance.no_of_seats).to eq(75)
|
@@ -78,48 +32,34 @@ describe Sapor::Wallonia, '#no_of_seats' do
|
|
78
32
|
end
|
79
33
|
|
80
34
|
describe Sapor::Wallonia, '#population_size' do
|
81
|
-
it 'returns a population size of 2,
|
82
|
-
expect(Sapor::Wallonia.instance.population_size).to eq(
|
35
|
+
it 'returns a population size of 2,034,813' do
|
36
|
+
expect(Sapor::Wallonia.instance.population_size).to eq(2_034_813)
|
83
37
|
end
|
84
38
|
end
|
85
39
|
|
86
40
|
describe Sapor::Wallonia, '#seats' do
|
87
|
-
it 'calculates the number of seats for the election of
|
41
|
+
it 'calculates the number of seats for the election of 2019' do
|
88
42
|
Wallonia = Sapor::Wallonia.instance
|
89
|
-
results = Wallonia.
|
43
|
+
results = Wallonia.overall_election_results_of_2019
|
90
44
|
seats = Wallonia.seats(results)
|
91
|
-
|
92
|
-
expect(seats['
|
93
|
-
|
94
|
-
expect(seats['
|
95
|
-
|
96
|
-
expect(seats['
|
97
|
-
|
98
|
-
expect(seats['Ecolo']).to eq(6) # Correction for Hainaut?
|
99
|
-
# expect(seats['PTB']).to eq(2)
|
100
|
-
expect(seats['PTB']).to eq(4) # Correction for Hainaut?
|
101
|
-
expect(seats['Parti Populaire']).to eq(1)
|
45
|
+
expect(seats['Parti Socialiste']).to eq(23)
|
46
|
+
expect(seats['Mouvement Réformateur']).to eq(20)
|
47
|
+
expect(seats['Ecolo']).to eq(12)
|
48
|
+
expect(seats['Centre démocrate humaniste']).to eq(10)
|
49
|
+
expect(seats['Parti du Travail de Belgique']).to eq(10)
|
50
|
+
expect(seats['AGIR']).to eq(0)
|
51
|
+
expect(seats['Collectif Citoyen']).to eq(0)
|
102
52
|
expect(seats['DéFI']).to eq(0)
|
103
|
-
expect(seats['
|
104
|
-
expect(seats['
|
53
|
+
expect(seats['Demain']).to eq(0)
|
54
|
+
expect(seats['DierAnimal']).to eq(0)
|
105
55
|
expect(seats['La Droite']).to eq(0)
|
106
|
-
expect(seats['
|
107
|
-
expect(seats['Atomique']).to eq(0)
|
108
|
-
expect(seats['FW']).to eq(0)
|
109
|
-
expect(seats['ISLAM']).to eq(0)
|
56
|
+
expect(seats['Listes Destexhe']).to eq(0)
|
110
57
|
expect(seats['NATION']).to eq(0)
|
111
|
-
expect(seats['
|
112
|
-
expect(seats['
|
113
|
-
expect(seats['
|
114
|
-
expect(seats['
|
115
|
-
expect(seats['
|
116
|
-
expect(seats['Rassemblement R']).to eq(0)
|
117
|
-
expect(seats['Rassemblement Wallon']).to eq(0)
|
118
|
-
expect(seats['R.W.F.']).to eq(0)
|
119
|
-
expect(seats['UdL']).to eq(0)
|
120
|
-
expect(seats['Union des Liberaux']).to eq(0)
|
121
|
-
expect(seats['VLC']).to eq(0)
|
122
|
-
expect(seats["Wallonie d’Abord"]).to eq(0)
|
58
|
+
expect(seats['Parti Communiste de Belgique']).to eq(0)
|
59
|
+
expect(seats['Parti Populaire']).to eq(0)
|
60
|
+
expect(seats['REFERENDUM']).to eq(0)
|
61
|
+
expect(seats['Turquoise']).to eq(0)
|
62
|
+
expect(seats['Wallonie Insoumise']).to eq(0)
|
123
63
|
end
|
124
64
|
end
|
125
65
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sapor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Filip van Laenen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: SAPoR
|
14
14
|
email:
|
@@ -230,6 +230,7 @@ files:
|
|
230
230
|
- lib/sapor/regional_data/united_kingdom_with_tig.rb
|
231
231
|
- lib/sapor/regional_data/utopia.rb
|
232
232
|
- lib/sapor/regional_data/wallonia-2014.psv
|
233
|
+
- lib/sapor/regional_data/wallonia-20190526.psv
|
233
234
|
- lib/sapor/regional_data/wallonia.rb
|
234
235
|
- lib/sapor/representatives_polychotomy.rb
|
235
236
|
- lib/sapor/single_district_proportional.rb
|