sapor 0.3.0 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 022baea2f19fd416f2364d714b550b3405e9abe1c5771c0ae53bdb40f400d7d6
4
- data.tar.gz: 98b0325a4009471fcb4fa5359bbb3416967aec9eb20bebb2293380419193c39f
3
+ metadata.gz: f37ce8d35c3bf87a4504f0eb4f000f288e691009fe91bb2ed4886de92fcdac8e
4
+ data.tar.gz: d8f11473d8554ca16948079f5c902bee7b61206f6fd51b83ecdca1354863329b
5
5
  SHA512:
6
- metadata.gz: 283636d4ee9819c25a3ec1d644b8f0166c39647f7da20d1c6a18fbe9c93cd2c6e16e52c57fdc956f0c71bc2711159f872f1973a49afb50729a5d2c53c9ec0c32
7
- data.tar.gz: 04fcb296d85fc8a0be4edafb8742f5244da8bdd702f9046ab5c06ec13007bb623ef25a886f1c851472db9b06d08ed424783c9018c8a4d84b55064d7b8e8bc5a4
6
+ metadata.gz: 80c164dc69d557c13159444e7cbd0f435618020fb4a987a634beec653290e812c753ab0d849c78a86f506dcd37092f0dd80df2d99a73772901688efe349c278b
7
+ data.tar.gz: 5126c1dc5158a0c1a30c1b4d1196ebc3e10afe90bc61abcec1a46fb6f404a1e4050b96066a1dede4dd346fc58a0acf2cce1bed3d6cacde25dde248b0b94d44dc
@@ -49,7 +49,9 @@ module Sapor
49
49
 
50
50
  private
51
51
 
52
- COALITIONS = [['Cambiamo! (*)', 'Insieme (*)'],
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 = [['Cambiamo! (*)', 'Insieme (*)'],
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 25 May 2014
62
- # Source: Web page with the official results of the elections of 25 May
63
- # 2014, downloaded on 11 May 2018,
64
- # https://en.wikipedia.org/wiki/European_Parliament_election,_2014_(Luxembourg)
65
- POPULATION_SIZE = 1_172_614
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
- [%w(cdH Ecolo MR), %w(cdH Ecolo PS), %w(cdH MR), %w(cdH PS),
32
- %w(cdH PS PTB), %w(Ecolo MR), %w(Ecolo MR PS), %w(Ecolo PS),
33
- %w(Ecolo PS PTB), %w(Ecolo PTB), %w(MR PS), %w(PS PTB)]
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 overall_election_results_of_2014
41
- if @overall_election_results_of_2014.nil?
42
- @overall_election_results_of_2014 = \
43
- summarize_election_results(election_results_of_2014)
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
- @overall_election_results_of_2014
60
+ @overall_election_results_of_2019
46
61
  end
47
62
 
48
63
  def population_size
49
- # Voter turnout on 25 May 2014
50
- # Source: http://elections2014.belgium.be/fr/wal/results/results_tab_WLR00000.html
51
- # Retrieved on 21 July 2017
52
- 2_047_387
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 Wallon' => 8,
68
- 'Hainaut' => 28,
82
+ SEAT_DISTRIBUTION = { 'Brabant wallon' => 8,
83
+ 'Hainaut' => 27,
69
84
  'Liège' => 23,
70
- 'Luxembourg' => 5,
85
+ 'Luxembourg' => 6,
71
86
  'Namur' => 11 }.freeze
72
87
 
73
88
  THRESHOLD = 0.05
74
89
 
75
- def election_results_of_2014
76
- if @election_results_of_2014.nil?
77
- @election_results_of_2014 = load_election_results( \
78
- 'wallonia-2014.psv'
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
- @election_results_of_2014
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
- overall_election_results_of_2014,
88
- election_results_of_2014,
102
+ overall_election_results_of_2019,
103
+ election_results_of_2019,
89
104
  SEAT_DISTRIBUTION,
90
105
  DhondtDenominators,
91
106
  THRESHOLD
@@ -19,7 +19,7 @@
19
19
 
20
20
  Gem::Specification.new do |gem|
21
21
  gem.name = 'sapor'
22
- gem.version = '0.3.0'
22
+ gem.version = '0.3.3'
23
23
  gem.authors = ['Filip van Laenen']
24
24
  gem.email = ['f.a.vanlaenen@ieee.org']
25
25
 
@@ -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,172,614' do
35
+ it 'returns a population size of 1,254,363' do
36
36
  expect(Sapor::EuropeanUnionLuxembourg.instance.population_size).to \
37
- eq(1_172_614)
37
+ eq(1_254_363)
38
38
  end
39
39
  end
40
40
 
@@ -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,047,387' do
82
- expect(Sapor::Wallonia.instance.population_size).to eq(2_047_387)
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 2014' do
41
+ it 'calculates the number of seats for the election of 2019' do
88
42
  Wallonia = Sapor::Wallonia.instance
89
- results = Wallonia.overall_election_results_of_2014
43
+ results = Wallonia.overall_election_results_of_2019
90
44
  seats = Wallonia.seats(results)
91
- # expect(seats['PS']).to eq(30)
92
- expect(seats['PS']).to eq(28) # Correction for Hainaut?
93
- # expect(seats['MR']).to eq(25)
94
- expect(seats['MR']).to eq(24) # Correction for Hainaut?
95
- # expect(seats['cdH']).to eq(13)
96
- expect(seats['cdH']).to eq(12) # Correction for Hainaut?
97
- # expect(seats['Ecolo']).to eq(4)
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['MG']).to eq(0)
104
- expect(seats['VEGA']).to eq(0)
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['Debout les Belges']).to eq(0)
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['NWA']).to eq(0)
112
- expect(seats['P+']).to eq(0)
113
- expect(seats['PIRATE']).to eq(0)
114
- expect(seats['PP PARTIPENSIONNES']).to eq(0)
115
- expect(seats['R']).to eq(0)
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.0
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-30 00:00:00.000000000 Z
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