sapor 0.3.4 → 0.3.5
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 +4 -4
- data/lib/sapor/poll.rb +3 -5
- data/lib/sapor/regional_data/{european_union_france_2019.rb → european_union_27_france.rb} +10 -10
- data/lib/sapor/regional_data/european_union_france.rb +8 -8
- data/lib/sapor/regional_data/european_union_latvia.rb +5 -5
- data/lib/sapor/regional_data/european_union_luxembourg.rb +1 -1
- data/lib/sapor/regional_data/greece.rb +5 -5
- data/lib/sapor/regional_data/latvia-20181006.psv +104 -0
- data/lib/sapor/regional_data/latvia.rb +43 -44
- data/lib/sapor/regional_data/luxembourg-20131020.psv +0 -16
- data/lib/sapor/regional_data/luxembourg-20181014.psv +59 -0
- data/lib/sapor/regional_data/luxembourg.rb +26 -20
- data/lib/sapor.rb +1 -4
- data/sapor.gemspec +1 -1
- data/spec/unit/{european_union_france_2019_spec.rb → european_union_27_france_spec.rb} +11 -11
- data/spec/unit/european_union_france_spec.rb +2 -2
- data/spec/unit/greece_spec.rb +2 -2
- data/spec/unit/latvia_spec.rb +19 -17
- data/spec/unit/luxembourg_spec.rb +13 -12
- metadata +7 -14
- data/lib/sapor/regional_data/latvia_kpv.rb +0 -112
- data/lib/sapor/regional_data/latvia_kpv_p_par.rb +0 -112
- data/lib/sapor/regional_data/latvia_kpv_par.rb +0 -112
- data/spec/unit/latvia_kpv_p_par_spec.rb +0 -38
- data/spec/unit/latvia_kpv_par_spec.rb +0 -38
- data/spec/unit/latvia_kpv_spec.rb +0 -38
@@ -32,9 +32,9 @@ describe Sapor::EuropeanUnionFrance, '#no_of_seats' do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
describe Sapor::EuropeanUnionFrance, '#population_size' do
|
35
|
-
it 'returns a population size of
|
35
|
+
it 'returns a population size of 22,655,174' do
|
36
36
|
expect(Sapor::EuropeanUnionFrance.instance.population_size).to \
|
37
|
-
eq(
|
37
|
+
eq(22_655_174)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
data/spec/unit/greece_spec.rb
CHANGED
@@ -32,8 +32,8 @@ describe Sapor::Greece, '#no_of_seats' do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
describe Sapor::Greece, '#population_size' do
|
35
|
-
it 'returns a population size of 5,
|
36
|
-
expect(Sapor::Greece.instance.population_size).to eq(
|
35
|
+
it 'returns a population size of 5,769,542' do
|
36
|
+
expect(Sapor::Greece.instance.population_size).to eq(5_769_542)
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
data/spec/unit/latvia_spec.rb
CHANGED
@@ -31,30 +31,32 @@ describe Sapor::Latvia, '#no_of_seats' do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
describe Sapor::Latvia, '#population_size' do
|
34
|
-
it 'returns a population size of
|
35
|
-
expect(Sapor::Latvia.instance.population_size).to eq(
|
34
|
+
it 'returns a population size of 839,000' do
|
35
|
+
expect(Sapor::Latvia.instance.population_size).to eq(839_000)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
39
|
describe Sapor::Latvia, '#seats' do
|
40
|
-
it 'calculates the number of seats for the election of
|
40
|
+
it 'calculates the number of seats for the election of 2018 correctly' do
|
41
41
|
Latvia = Sapor::Latvia.instance
|
42
|
-
results = Latvia.
|
42
|
+
results = Latvia.overall_election_results_of_2018
|
43
43
|
seats = Latvia.seats(results)
|
44
|
-
expect(seats['Sociāldemokrātiskā
|
45
|
-
expect(seats['
|
46
|
-
expect(seats['
|
44
|
+
expect(seats['Sociāldemokrātiskā partija “Saskaņa”']).to eq(23)
|
45
|
+
expect(seats['Politiskā partija „KPV LV”']).to eq(16)
|
46
|
+
expect(seats['Jaunā konservatīvā partija']).to eq(16)
|
47
47
|
expect(seats['Nacionālā apvienība „Visu Latvijai!”–„Tēvzemei un ' \
|
48
|
-
'Brīvībai/LNNK”']).to eq(
|
49
|
-
expect(seats['
|
50
|
-
expect(seats['
|
48
|
+
'Brīvībai/LNNK”']).to eq(13)
|
49
|
+
expect(seats['Attīstībai/Par!']).to eq(13)
|
50
|
+
expect(seats['Zaļo un Zemnieku savienība']).to eq(11)
|
51
|
+
expect(seats['Jaunā VIENOTĪBA']).to eq(8)
|
52
|
+
expect(seats['Latvijas Reģionu Apvienība']).to eq(0)
|
51
53
|
expect(seats['Latvijas Krievu savienība']).to eq(0)
|
52
|
-
expect(seats['
|
53
|
-
expect(seats['
|
54
|
-
expect(seats['
|
55
|
-
|
56
|
-
expect(seats['
|
57
|
-
expect(seats['
|
58
|
-
expect(seats['
|
54
|
+
expect(seats['PROGRESĪVIE']).to eq(0)
|
55
|
+
expect(seats['No sirds Latvijai']).to eq(0)
|
56
|
+
expect(seats['Latviešu Nacionālisti']).to eq(0)
|
57
|
+
expect(seats['Par Alternatīvu']).to eq(0)
|
58
|
+
expect(seats['Apvienība SKG']).to eq(0)
|
59
|
+
expect(seats['Rīcības partija']).to eq(0)
|
60
|
+
expect(seats['Latvijas centriskā partija']).to eq(0)
|
59
61
|
end
|
60
62
|
end
|
@@ -31,24 +31,25 @@ describe Sapor::Luxembourg, '#no_of_seats' do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
describe Sapor::Luxembourg, '#population_size' do
|
34
|
-
it 'returns a population size of 3,
|
35
|
-
expect(Sapor::Luxembourg.instance.population_size).to eq(
|
34
|
+
it 'returns a population size of 3,529,969' do
|
35
|
+
expect(Sapor::Luxembourg.instance.population_size).to eq(3_529_969)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
39
|
describe Sapor::Luxembourg, '#seats' do
|
40
|
-
it 'calculates the number of seats for the election of
|
40
|
+
it 'calculates the number of seats for the election of 2018 correctly' do
|
41
41
|
Luxembourg = Sapor::Luxembourg.instance
|
42
|
-
results = Luxembourg.
|
42
|
+
results = Luxembourg.overall_election_results_of_2018
|
43
43
|
seats = Luxembourg.seats(results)
|
44
|
-
expect(seats['Chrëschtlech-Sozial Vollekspartei']).to eq(
|
45
|
-
expect(seats['Lëtzebuerger Sozialistesch Aarbechterpartei']).to eq(
|
46
|
-
expect(seats['Demokratesch Partei']).to eq(
|
47
|
-
expect(seats['déi gréng']).to eq(
|
48
|
-
expect(seats['Alternativ Demokratesch Reformpartei']).to eq(
|
49
|
-
expect(seats['
|
50
|
-
expect(seats['Piratepartei Lëtzebuerg']).to eq(
|
44
|
+
expect(seats['Chrëschtlech-Sozial Vollekspartei']).to eq(21)
|
45
|
+
expect(seats['Lëtzebuerger Sozialistesch Aarbechterpartei']).to eq(10)
|
46
|
+
expect(seats['Demokratesch Partei']).to eq(12)
|
47
|
+
expect(seats['déi gréng']).to eq(9)
|
48
|
+
expect(seats['Alternativ Demokratesch Reformpartei']).to eq(4)
|
49
|
+
expect(seats['déi Lénk']).to eq(2)
|
50
|
+
expect(seats['Piratepartei Lëtzebuerg']).to eq(2)
|
51
51
|
expect(seats['Kommunistesch Partei Lëtzebuerg']).to eq(0)
|
52
|
-
expect(seats['
|
52
|
+
expect(seats['Demokratie']).to eq(0)
|
53
|
+
expect(seats['déi Konservativ']).to eq(0)
|
53
54
|
end
|
54
55
|
end
|
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.5
|
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-12-
|
11
|
+
date: 2019-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: SAPoR
|
14
14
|
email:
|
@@ -118,6 +118,7 @@ files:
|
|
118
118
|
- lib/sapor/regional_data/european_union_27_denmark.rb
|
119
119
|
- lib/sapor/regional_data/european_union_27_estonia.rb
|
120
120
|
- lib/sapor/regional_data/european_union_27_finland.rb
|
121
|
+
- lib/sapor/regional_data/european_union_27_france.rb
|
121
122
|
- lib/sapor/regional_data/european_union_27_ireland.rb
|
122
123
|
- lib/sapor/regional_data/european_union_27_ireland_with_ia.rb
|
123
124
|
- lib/sapor/regional_data/european_union_27_italy.rb
|
@@ -137,7 +138,6 @@ files:
|
|
137
138
|
- lib/sapor/regional_data/european_union_finland.rb
|
138
139
|
- lib/sapor/regional_data/european_union_flanders.rb
|
139
140
|
- lib/sapor/regional_data/european_union_france.rb
|
140
|
-
- lib/sapor/regional_data/european_union_france_2019.rb
|
141
141
|
- lib/sapor/regional_data/european_union_french_community_of_belgium.rb
|
142
142
|
- lib/sapor/regional_data/european_union_germany.rb
|
143
143
|
- lib/sapor/regional_data/european_union_great_britain.rb
|
@@ -178,11 +178,10 @@ files:
|
|
178
178
|
- lib/sapor/regional_data/latvia-20141004-kpv-par.psv
|
179
179
|
- lib/sapor/regional_data/latvia-20141004-kpv.psv
|
180
180
|
- lib/sapor/regional_data/latvia-20141004.psv
|
181
|
+
- lib/sapor/regional_data/latvia-20181006.psv
|
181
182
|
- lib/sapor/regional_data/latvia.rb
|
182
|
-
- lib/sapor/regional_data/latvia_kpv.rb
|
183
|
-
- lib/sapor/regional_data/latvia_kpv_p_par.rb
|
184
|
-
- lib/sapor/regional_data/latvia_kpv_par.rb
|
185
183
|
- lib/sapor/regional_data/luxembourg-20131020.psv
|
184
|
+
- lib/sapor/regional_data/luxembourg-20181014.psv
|
186
185
|
- lib/sapor/regional_data/luxembourg.rb
|
187
186
|
- lib/sapor/regional_data/netherlands.rb
|
188
187
|
- lib/sapor/regional_data/norway.rb
|
@@ -261,6 +260,7 @@ files:
|
|
261
260
|
- spec/unit/european_union_27_denmark_spec.rb
|
262
261
|
- spec/unit/european_union_27_estonia_spec.rb
|
263
262
|
- spec/unit/european_union_27_finland_spec.rb
|
263
|
+
- spec/unit/european_union_27_france_spec.rb
|
264
264
|
- spec/unit/european_union_27_ireland_spec.rb
|
265
265
|
- spec/unit/european_union_27_ireland_with_ia_spec.rb
|
266
266
|
- spec/unit/european_union_27_italy_spec.rb
|
@@ -279,7 +279,6 @@ files:
|
|
279
279
|
- spec/unit/european_union_estonia_spec.rb
|
280
280
|
- spec/unit/european_union_finland_spec.rb
|
281
281
|
- spec/unit/european_union_flanders_spec.rb
|
282
|
-
- spec/unit/european_union_france_2019_spec.rb
|
283
282
|
- spec/unit/european_union_france_spec.rb
|
284
283
|
- spec/unit/european_union_french_community_of_belgium_spec.rb
|
285
284
|
- spec/unit/european_union_germany_spec.rb
|
@@ -311,9 +310,6 @@ files:
|
|
311
310
|
- spec/unit/hungary_spec.rb
|
312
311
|
- spec/unit/iceland_spec.rb
|
313
312
|
- spec/unit/largest_remainder_spec.rb
|
314
|
-
- spec/unit/latvia_kpv_p_par_spec.rb
|
315
|
-
- spec/unit/latvia_kpv_par_spec.rb
|
316
|
-
- spec/unit/latvia_kpv_spec.rb
|
317
313
|
- spec/unit/latvia_spec.rb
|
318
314
|
- spec/unit/luxembourg_spec.rb
|
319
315
|
- spec/unit/multi_district_leveled_proportional_spec.rb
|
@@ -400,6 +396,7 @@ test_files:
|
|
400
396
|
- spec/unit/european_union_27_denmark_spec.rb
|
401
397
|
- spec/unit/european_union_27_estonia_spec.rb
|
402
398
|
- spec/unit/european_union_27_finland_spec.rb
|
399
|
+
- spec/unit/european_union_27_france_spec.rb
|
403
400
|
- spec/unit/european_union_27_ireland_spec.rb
|
404
401
|
- spec/unit/european_union_27_ireland_with_ia_spec.rb
|
405
402
|
- spec/unit/european_union_27_italy_spec.rb
|
@@ -418,7 +415,6 @@ test_files:
|
|
418
415
|
- spec/unit/european_union_estonia_spec.rb
|
419
416
|
- spec/unit/european_union_finland_spec.rb
|
420
417
|
- spec/unit/european_union_flanders_spec.rb
|
421
|
-
- spec/unit/european_union_france_2019_spec.rb
|
422
418
|
- spec/unit/european_union_france_spec.rb
|
423
419
|
- spec/unit/european_union_french_community_of_belgium_spec.rb
|
424
420
|
- spec/unit/european_union_germany_spec.rb
|
@@ -450,9 +446,6 @@ test_files:
|
|
450
446
|
- spec/unit/hungary_spec.rb
|
451
447
|
- spec/unit/iceland_spec.rb
|
452
448
|
- spec/unit/largest_remainder_spec.rb
|
453
|
-
- spec/unit/latvia_kpv_p_par_spec.rb
|
454
|
-
- spec/unit/latvia_kpv_par_spec.rb
|
455
|
-
- spec/unit/latvia_kpv_spec.rb
|
456
449
|
- spec/unit/latvia_spec.rb
|
457
450
|
- spec/unit/luxembourg_spec.rb
|
458
451
|
- spec/unit/multi_district_leveled_proportional_spec.rb
|
@@ -1,112 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Statistical Analysis of Polling Results (SAPoR)
|
3
|
-
# Copyright (C) 2016 Filip van Laenen <f.a.vanlaenen@ieee.org>
|
4
|
-
#
|
5
|
-
# This file is part of SAPoR.
|
6
|
-
#
|
7
|
-
# SAPoR is free software: you can redistribute it and/or modify it under the
|
8
|
-
# terms of the GNU General Public License as published by the Free Software
|
9
|
-
# Foundation, either version 3 of the License, or (at your option) any later
|
10
|
-
# version.
|
11
|
-
#
|
12
|
-
# SAPoR is distributed in the hope that it will be useful, but WITHOUT ANY
|
13
|
-
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
14
|
-
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
15
|
-
#
|
16
|
-
# You can find a copy of the GNU General Public License in /doc/gpl.txt
|
17
|
-
#
|
18
|
-
|
19
|
-
module Sapor
|
20
|
-
#
|
21
|
-
# The regional data for Latvia, extended for KPV.
|
22
|
-
#
|
23
|
-
class LatviaKpv < Area
|
24
|
-
include Singleton
|
25
|
-
def area_code
|
26
|
-
'LV∪{KPV}'
|
27
|
-
end
|
28
|
-
|
29
|
-
def coalitions
|
30
|
-
[['KPV LV', 'Sociāldemokrātiskā Partija “Saskaņa”'],
|
31
|
-
['KPV LV', 'Sociāldemokrātiskā Partija “Saskaņa”',
|
32
|
-
'Zaļo un Zemnieku savienība'],
|
33
|
-
['Kustība Par!',
|
34
|
-
'Nacionālā apvienība „Visu Latvijai!”–„Tēvzemei un Brīvībai/LNNK”',
|
35
|
-
'Vienotība', 'Zaļo un Zemnieku savienība'],
|
36
|
-
['Kustība Par!',
|
37
|
-
'Nacionālā apvienība „Visu Latvijai!”–„Tēvzemei un Brīvībai/LNNK”',
|
38
|
-
'Zaļo un Zemnieku savienība'],
|
39
|
-
['Kustība Par!', 'Jaunā konservatīvā partija',
|
40
|
-
'Nacionālā apvienība „Visu Latvijai!”–„Tēvzemei un Brīvībai/LNNK”',
|
41
|
-
'Vienotība'],
|
42
|
-
['Kustība Par!', 'Jaunā konservatīvā partija',
|
43
|
-
'Nacionālā apvienība „Visu Latvijai!”–„Tēvzemei un Brīvībai/LNNK”',
|
44
|
-
'Vienotība', 'Zaļo un Zemnieku savienība'],
|
45
|
-
['Kustība Par!', 'Jaunā konservatīvā partija',
|
46
|
-
'Nacionālā apvienība „Visu Latvijai!”–„Tēvzemei un Brīvībai/LNNK”',
|
47
|
-
'Zaļo un Zemnieku savienība'],
|
48
|
-
['Kustība Par!', 'Jaunā konservatīvā partija',
|
49
|
-
'Sociāldemokrātiskā Partija “Saskaņa”'],
|
50
|
-
['Kustība Par!', 'Sociāldemokrātiskā Partija “Saskaņa”'],
|
51
|
-
['Jaunā konservatīvā partija',
|
52
|
-
'Nacionālā apvienība „Visu Latvijai!”–„Tēvzemei un Brīvībai/LNNK”',
|
53
|
-
'Vienotība', 'Zaļo un Zemnieku savienība'],
|
54
|
-
['Jaunā konservatīvā partija',
|
55
|
-
'Nacionālā apvienība „Visu Latvijai!”–„Tēvzemei un Brīvībai/LNNK”',
|
56
|
-
'Zaļo un Zemnieku savienība'],
|
57
|
-
['Nacionālā apvienība „Visu Latvijai!”–„Tēvzemei un Brīvībai/LNNK”',
|
58
|
-
'Vienotība', 'Zaļo un Zemnieku savienība']]
|
59
|
-
end
|
60
|
-
|
61
|
-
def no_of_seats
|
62
|
-
SEAT_DISTRIBUTION.values.inject(:+)
|
63
|
-
end
|
64
|
-
|
65
|
-
def overall_election_results_of_2014
|
66
|
-
if @overall_election_results_of_2014.nil?
|
67
|
-
@overall_election_results_of_2014 = \
|
68
|
-
summarize_election_results(election_results_of_2014)
|
69
|
-
end
|
70
|
-
@overall_election_results_of_2014
|
71
|
-
end
|
72
|
-
|
73
|
-
def population_size
|
74
|
-
# Voter turnout on 4 October 2014
|
75
|
-
913_491
|
76
|
-
end
|
77
|
-
|
78
|
-
def seats(simulation)
|
79
|
-
electoral_system.project(simulation)
|
80
|
-
end
|
81
|
-
|
82
|
-
def threshold
|
83
|
-
THRESHOLD
|
84
|
-
end
|
85
|
-
|
86
|
-
private
|
87
|
-
|
88
|
-
SEAT_DISTRIBUTION = { 'Kurzeme' => 13, 'Latgale' => 15, 'Rīga' => 32,
|
89
|
-
'Vidzeme' => 26, 'Zemgale' => 14 }.freeze
|
90
|
-
|
91
|
-
THRESHOLD = 0.05
|
92
|
-
|
93
|
-
def election_results_of_2014
|
94
|
-
if @election_results_of_2014.nil?
|
95
|
-
@election_results_of_2014 = load_election_results(
|
96
|
-
'latvia-20141004-kpv.psv'
|
97
|
-
)
|
98
|
-
end
|
99
|
-
@election_results_of_2014
|
100
|
-
end
|
101
|
-
|
102
|
-
def electoral_system
|
103
|
-
if @electoral_system.nil?
|
104
|
-
@electoral_system = MultiDistrictProportional.new( \
|
105
|
-
overall_election_results_of_2014, election_results_of_2014,
|
106
|
-
SEAT_DISTRIBUTION, SainteLagueDenominators, 0, THRESHOLD
|
107
|
-
)
|
108
|
-
end
|
109
|
-
@electoral_system
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
@@ -1,112 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Statistical Analysis of Polling Results (SAPoR)
|
3
|
-
# Copyright (C) 2016 Filip van Laenen <f.a.vanlaenen@ieee.org>
|
4
|
-
#
|
5
|
-
# This file is part of SAPoR.
|
6
|
-
#
|
7
|
-
# SAPoR is free software: you can redistribute it and/or modify it under the
|
8
|
-
# terms of the GNU General Public License as published by the Free Software
|
9
|
-
# Foundation, either version 3 of the License, or (at your option) any later
|
10
|
-
# version.
|
11
|
-
#
|
12
|
-
# SAPoR is distributed in the hope that it will be useful, but WITHOUT ANY
|
13
|
-
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
14
|
-
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
15
|
-
#
|
16
|
-
# You can find a copy of the GNU General Public License in /doc/gpl.txt
|
17
|
-
#
|
18
|
-
|
19
|
-
module Sapor
|
20
|
-
#
|
21
|
-
# The regional data for Latvia, extended for KPV, P and PAR.
|
22
|
-
#
|
23
|
-
class LatviaKpvPPar < Area
|
24
|
-
include Singleton
|
25
|
-
def area_code
|
26
|
-
'LV∪{KPV,P,PAR}'
|
27
|
-
end
|
28
|
-
|
29
|
-
def coalitions
|
30
|
-
[['KPV LV', 'Sociāldemokrātiskā Partija “Saskaņa”'],
|
31
|
-
['KPV LV', 'Sociāldemokrātiskā Partija “Saskaņa”',
|
32
|
-
'Zaļo un Zemnieku savienība'],
|
33
|
-
['Kustība Par!',
|
34
|
-
'Nacionālā apvienība „Visu Latvijai!”–„Tēvzemei un Brīvībai/LNNK”',
|
35
|
-
'Vienotība', 'Zaļo un Zemnieku savienība'],
|
36
|
-
['Kustība Par!',
|
37
|
-
'Nacionālā apvienība „Visu Latvijai!”–„Tēvzemei un Brīvībai/LNNK”',
|
38
|
-
'Zaļo un Zemnieku savienība'],
|
39
|
-
['Kustība Par!', 'Jaunā konservatīvā partija',
|
40
|
-
'Nacionālā apvienība „Visu Latvijai!”–„Tēvzemei un Brīvībai/LNNK”',
|
41
|
-
'Vienotība'],
|
42
|
-
['Kustība Par!', 'Jaunā konservatīvā partija',
|
43
|
-
'Nacionālā apvienība „Visu Latvijai!”–„Tēvzemei un Brīvībai/LNNK”',
|
44
|
-
'Vienotība', 'Zaļo un Zemnieku savienība'],
|
45
|
-
['Kustība Par!', 'Jaunā konservatīvā partija',
|
46
|
-
'Nacionālā apvienība „Visu Latvijai!”–„Tēvzemei un Brīvībai/LNNK”',
|
47
|
-
'Zaļo un Zemnieku savienība'],
|
48
|
-
['Kustība Par!', 'Jaunā konservatīvā partija',
|
49
|
-
'Sociāldemokrātiskā Partija “Saskaņa”'],
|
50
|
-
['Kustība Par!', 'Sociāldemokrātiskā Partija “Saskaņa”'],
|
51
|
-
['Jaunā konservatīvā partija',
|
52
|
-
'Nacionālā apvienība „Visu Latvijai!”–„Tēvzemei un Brīvībai/LNNK”',
|
53
|
-
'Vienotība', 'Zaļo un Zemnieku savienība'],
|
54
|
-
['Jaunā konservatīvā partija',
|
55
|
-
'Nacionālā apvienība „Visu Latvijai!”–„Tēvzemei un Brīvībai/LNNK”',
|
56
|
-
'Zaļo un Zemnieku savienība'],
|
57
|
-
['Nacionālā apvienība „Visu Latvijai!”–„Tēvzemei un Brīvībai/LNNK”',
|
58
|
-
'Vienotība', 'Zaļo un Zemnieku savienība']]
|
59
|
-
end
|
60
|
-
|
61
|
-
def no_of_seats
|
62
|
-
SEAT_DISTRIBUTION.values.inject(:+)
|
63
|
-
end
|
64
|
-
|
65
|
-
def overall_election_results_of_2014
|
66
|
-
if @overall_election_results_of_2014.nil?
|
67
|
-
@overall_election_results_of_2014 = \
|
68
|
-
summarize_election_results(election_results_of_2014)
|
69
|
-
end
|
70
|
-
@overall_election_results_of_2014
|
71
|
-
end
|
72
|
-
|
73
|
-
def population_size
|
74
|
-
# Voter turnout on 4 October 2014
|
75
|
-
913_491
|
76
|
-
end
|
77
|
-
|
78
|
-
def seats(simulation)
|
79
|
-
electoral_system.project(simulation)
|
80
|
-
end
|
81
|
-
|
82
|
-
def threshold
|
83
|
-
THRESHOLD
|
84
|
-
end
|
85
|
-
|
86
|
-
private
|
87
|
-
|
88
|
-
SEAT_DISTRIBUTION = { 'Kurzeme' => 13, 'Latgale' => 15, 'Rīga' => 32,
|
89
|
-
'Vidzeme' => 26, 'Zemgale' => 14 }.freeze
|
90
|
-
|
91
|
-
THRESHOLD = 0.05
|
92
|
-
|
93
|
-
def election_results_of_2014
|
94
|
-
if @election_results_of_2014.nil?
|
95
|
-
@election_results_of_2014 = load_election_results(
|
96
|
-
'latvia-20141004-kpv-p-par.psv'
|
97
|
-
)
|
98
|
-
end
|
99
|
-
@election_results_of_2014
|
100
|
-
end
|
101
|
-
|
102
|
-
def electoral_system
|
103
|
-
if @electoral_system.nil?
|
104
|
-
@electoral_system = MultiDistrictProportional.new( \
|
105
|
-
overall_election_results_of_2014, election_results_of_2014,
|
106
|
-
SEAT_DISTRIBUTION, SainteLagueDenominators, 0, THRESHOLD
|
107
|
-
)
|
108
|
-
end
|
109
|
-
@electoral_system
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
@@ -1,112 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Statistical Analysis of Polling Results (SAPoR)
|
3
|
-
# Copyright (C) 2016 Filip van Laenen <f.a.vanlaenen@ieee.org>
|
4
|
-
#
|
5
|
-
# This file is part of SAPoR.
|
6
|
-
#
|
7
|
-
# SAPoR is free software: you can redistribute it and/or modify it under the
|
8
|
-
# terms of the GNU General Public License as published by the Free Software
|
9
|
-
# Foundation, either version 3 of the License, or (at your option) any later
|
10
|
-
# version.
|
11
|
-
#
|
12
|
-
# SAPoR is distributed in the hope that it will be useful, but WITHOUT ANY
|
13
|
-
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
14
|
-
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
15
|
-
#
|
16
|
-
# You can find a copy of the GNU General Public License in /doc/gpl.txt
|
17
|
-
#
|
18
|
-
|
19
|
-
module Sapor
|
20
|
-
#
|
21
|
-
# The regional data for Latvia, extended for KPV and PAR.
|
22
|
-
#
|
23
|
-
class LatviaKpvPar < Area
|
24
|
-
include Singleton
|
25
|
-
def area_code
|
26
|
-
'LV∪{KPV,PAR}'
|
27
|
-
end
|
28
|
-
|
29
|
-
def coalitions
|
30
|
-
[['KPV LV', 'Sociāldemokrātiskā Partija “Saskaņa”'],
|
31
|
-
['KPV LV', 'Sociāldemokrātiskā Partija “Saskaņa”',
|
32
|
-
'Zaļo un Zemnieku savienība'],
|
33
|
-
['Kustība Par!',
|
34
|
-
'Nacionālā apvienība „Visu Latvijai!”–„Tēvzemei un Brīvībai/LNNK”',
|
35
|
-
'Vienotība', 'Zaļo un Zemnieku savienība'],
|
36
|
-
['Kustība Par!',
|
37
|
-
'Nacionālā apvienība „Visu Latvijai!”–„Tēvzemei un Brīvībai/LNNK”',
|
38
|
-
'Zaļo un Zemnieku savienība'],
|
39
|
-
['Kustība Par!', 'Jaunā konservatīvā partija',
|
40
|
-
'Nacionālā apvienība „Visu Latvijai!”–„Tēvzemei un Brīvībai/LNNK”',
|
41
|
-
'Vienotība'],
|
42
|
-
['Kustība Par!', 'Jaunā konservatīvā partija',
|
43
|
-
'Nacionālā apvienība „Visu Latvijai!”–„Tēvzemei un Brīvībai/LNNK”',
|
44
|
-
'Vienotība', 'Zaļo un Zemnieku savienība'],
|
45
|
-
['Kustība Par!', 'Jaunā konservatīvā partija',
|
46
|
-
'Nacionālā apvienība „Visu Latvijai!”–„Tēvzemei un Brīvībai/LNNK”',
|
47
|
-
'Zaļo un Zemnieku savienība'],
|
48
|
-
['Kustība Par!', 'Jaunā konservatīvā partija',
|
49
|
-
'Sociāldemokrātiskā Partija “Saskaņa”'],
|
50
|
-
['Kustība Par!', 'Sociāldemokrātiskā Partija “Saskaņa”'],
|
51
|
-
['Jaunā konservatīvā partija',
|
52
|
-
'Nacionālā apvienība „Visu Latvijai!”–„Tēvzemei un Brīvībai/LNNK”',
|
53
|
-
'Vienotība', 'Zaļo un Zemnieku savienība'],
|
54
|
-
['Jaunā konservatīvā partija',
|
55
|
-
'Nacionālā apvienība „Visu Latvijai!”–„Tēvzemei un Brīvībai/LNNK”',
|
56
|
-
'Zaļo un Zemnieku savienība'],
|
57
|
-
['Nacionālā apvienība „Visu Latvijai!”–„Tēvzemei un Brīvībai/LNNK”',
|
58
|
-
'Vienotība', 'Zaļo un Zemnieku savienība']]
|
59
|
-
end
|
60
|
-
|
61
|
-
def no_of_seats
|
62
|
-
SEAT_DISTRIBUTION.values.inject(:+)
|
63
|
-
end
|
64
|
-
|
65
|
-
def overall_election_results_of_2014
|
66
|
-
if @overall_election_results_of_2014.nil?
|
67
|
-
@overall_election_results_of_2014 = \
|
68
|
-
summarize_election_results(election_results_of_2014)
|
69
|
-
end
|
70
|
-
@overall_election_results_of_2014
|
71
|
-
end
|
72
|
-
|
73
|
-
def population_size
|
74
|
-
# Voter turnout on 4 October 2014
|
75
|
-
913_491
|
76
|
-
end
|
77
|
-
|
78
|
-
def seats(simulation)
|
79
|
-
electoral_system.project(simulation)
|
80
|
-
end
|
81
|
-
|
82
|
-
def threshold
|
83
|
-
THRESHOLD
|
84
|
-
end
|
85
|
-
|
86
|
-
private
|
87
|
-
|
88
|
-
SEAT_DISTRIBUTION = { 'Kurzeme' => 13, 'Latgale' => 15, 'Rīga' => 32,
|
89
|
-
'Vidzeme' => 26, 'Zemgale' => 14 }.freeze
|
90
|
-
|
91
|
-
THRESHOLD = 0.05
|
92
|
-
|
93
|
-
def election_results_of_2014
|
94
|
-
if @election_results_of_2014.nil?
|
95
|
-
@election_results_of_2014 = load_election_results(
|
96
|
-
'latvia-20141004-kpv-par.psv'
|
97
|
-
)
|
98
|
-
end
|
99
|
-
@election_results_of_2014
|
100
|
-
end
|
101
|
-
|
102
|
-
def electoral_system
|
103
|
-
if @electoral_system.nil?
|
104
|
-
@electoral_system = MultiDistrictProportional.new( \
|
105
|
-
overall_election_results_of_2014, election_results_of_2014,
|
106
|
-
SEAT_DISTRIBUTION, SainteLagueDenominators, 0, THRESHOLD
|
107
|
-
)
|
108
|
-
end
|
109
|
-
@electoral_system
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
#
|
3
|
-
# Statistical Analysis of Polling Results (SAPoR)
|
4
|
-
# Copyright (C) 2016 Filip van Laenen <f.a.vanlaenen@ieee.org>
|
5
|
-
#
|
6
|
-
# This file is part of SAPoR.
|
7
|
-
#
|
8
|
-
# SAPoR is free software: you can redistribute it and/or modify it under the
|
9
|
-
# terms of the GNU General Public License as published by the Free Software
|
10
|
-
# Foundation, either version 3 of the License, or (at your option) any later
|
11
|
-
# version.
|
12
|
-
#
|
13
|
-
# SAPoR is distributed in the hope that it will be useful, but WITHOUT ANY
|
14
|
-
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
15
|
-
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
16
|
-
#
|
17
|
-
# You can find a copy of the GNU General Public License in /doc/gpl.txt
|
18
|
-
#
|
19
|
-
|
20
|
-
require 'spec_helper'
|
21
|
-
|
22
|
-
describe Sapor::LatviaKpvPPar, '#area_code' do
|
23
|
-
it 'returns LV∪{KPV,P,PAR} as the area code' do
|
24
|
-
expect(Sapor::LatviaKpvPPar.instance.area_code).to eq('LV∪{KPV,P,PAR}')
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe Sapor::LatviaKpvPPar, '#no_of_seats' do
|
29
|
-
it 'returns 100 as the number of seats' do
|
30
|
-
expect(Sapor::LatviaKpvPPar.instance.no_of_seats).to eq(100)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe Sapor::LatviaKpvPPar, '#population_size' do
|
35
|
-
it 'returns a population size of 913,491' do
|
36
|
-
expect(Sapor::LatviaKpvPPar.instance.population_size).to eq(913_491)
|
37
|
-
end
|
38
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
#
|
3
|
-
# Statistical Analysis of Polling Results (SAPoR)
|
4
|
-
# Copyright (C) 2016 Filip van Laenen <f.a.vanlaenen@ieee.org>
|
5
|
-
#
|
6
|
-
# This file is part of SAPoR.
|
7
|
-
#
|
8
|
-
# SAPoR is free software: you can redistribute it and/or modify it under the
|
9
|
-
# terms of the GNU General Public License as published by the Free Software
|
10
|
-
# Foundation, either version 3 of the License, or (at your option) any later
|
11
|
-
# version.
|
12
|
-
#
|
13
|
-
# SAPoR is distributed in the hope that it will be useful, but WITHOUT ANY
|
14
|
-
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
15
|
-
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
16
|
-
#
|
17
|
-
# You can find a copy of the GNU General Public License in /doc/gpl.txt
|
18
|
-
#
|
19
|
-
|
20
|
-
require 'spec_helper'
|
21
|
-
|
22
|
-
describe Sapor::LatviaKpvPar, '#area_code' do
|
23
|
-
it 'returns LV∪{KPV,PAR} as the area code' do
|
24
|
-
expect(Sapor::LatviaKpvPar.instance.area_code).to eq('LV∪{KPV,PAR}')
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe Sapor::LatviaKpvPar, '#no_of_seats' do
|
29
|
-
it 'returns 100 as the number of seats' do
|
30
|
-
expect(Sapor::LatviaKpvPar.instance.no_of_seats).to eq(100)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe Sapor::LatviaKpvPar, '#population_size' do
|
35
|
-
it 'returns a population size of 913,491' do
|
36
|
-
expect(Sapor::LatviaKpvPar.instance.population_size).to eq(913_491)
|
37
|
-
end
|
38
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
#
|
3
|
-
# Statistical Analysis of Polling Results (SAPoR)
|
4
|
-
# Copyright (C) 2016 Filip van Laenen <f.a.vanlaenen@ieee.org>
|
5
|
-
#
|
6
|
-
# This file is part of SAPoR.
|
7
|
-
#
|
8
|
-
# SAPoR is free software: you can redistribute it and/or modify it under the
|
9
|
-
# terms of the GNU General Public License as published by the Free Software
|
10
|
-
# Foundation, either version 3 of the License, or (at your option) any later
|
11
|
-
# version.
|
12
|
-
#
|
13
|
-
# SAPoR is distributed in the hope that it will be useful, but WITHOUT ANY
|
14
|
-
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
15
|
-
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
16
|
-
#
|
17
|
-
# You can find a copy of the GNU General Public License in /doc/gpl.txt
|
18
|
-
#
|
19
|
-
|
20
|
-
require 'spec_helper'
|
21
|
-
|
22
|
-
describe Sapor::LatviaKpv, '#area_code' do
|
23
|
-
it 'returns LV∪{KPV} as the area code' do
|
24
|
-
expect(Sapor::LatviaKpv.instance.area_code).to eq('LV∪{KPV}')
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe Sapor::LatviaKpv, '#no_of_seats' do
|
29
|
-
it 'returns 100 as the number of seats' do
|
30
|
-
expect(Sapor::LatviaKpv.instance.no_of_seats).to eq(100)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe Sapor::LatviaKpv, '#population_size' do
|
35
|
-
it 'returns a population size of 913,491' do
|
36
|
-
expect(Sapor::LatviaKpv.instance.population_size).to eq(913_491)
|
37
|
-
end
|
38
|
-
end
|