sapor 0.4.0 → 0.4.1

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.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/lib/sapor/poll.rb +1 -13
  3. data/lib/sapor/regional_data/european_union_austria.rb +1 -1
  4. data/lib/sapor/regional_data/european_union_croatia.rb +1 -1
  5. data/lib/sapor/regional_data/european_union_denmark.rb +1 -1
  6. data/lib/sapor/regional_data/european_union_estonia.rb +1 -1
  7. data/lib/sapor/regional_data/european_union_finland.rb +1 -1
  8. data/lib/sapor/regional_data/european_union_france.rb +1 -1
  9. data/lib/sapor/regional_data/european_union_ireland.rb +2 -2
  10. data/lib/sapor/regional_data/european_union_ireland_with_ia.rb +2 -2
  11. data/lib/sapor/regional_data/european_union_italy.rb +1 -1
  12. data/lib/sapor/regional_data/european_union_netherlands.rb +1 -1
  13. data/lib/sapor/regional_data/european_union_poland.rb +1 -1
  14. data/lib/sapor/regional_data/european_union_spain.rb +1 -1
  15. data/lib/sapor.rb +0 -12
  16. data/sapor.gemspec +1 -1
  17. data/spec/unit/european_union_austria_spec.rb +3 -3
  18. data/spec/unit/european_union_croatia_spec.rb +5 -4
  19. data/spec/unit/european_union_denmark_spec.rb +5 -4
  20. data/spec/unit/european_union_estonia_spec.rb +5 -4
  21. data/spec/unit/european_union_finland_spec.rb +3 -3
  22. data/spec/unit/european_union_france_spec.rb +6 -6
  23. data/spec/unit/european_union_ireland_spec.rb +4 -4
  24. data/spec/unit/european_union_ireland_with_ia_spec.rb +4 -4
  25. data/spec/unit/european_union_italy_spec.rb +5 -5
  26. data/spec/unit/european_union_netherlands_spec.rb +5 -5
  27. data/spec/unit/european_union_poland_spec.rb +3 -3
  28. data/spec/unit/european_union_spain_spec.rb +7 -6
  29. metadata +2 -38
  30. data/lib/sapor/regional_data/european_union_27_austria.rb +0 -76
  31. data/lib/sapor/regional_data/european_union_27_croatia.rb +0 -83
  32. data/lib/sapor/regional_data/european_union_27_denmark.rb +0 -77
  33. data/lib/sapor/regional_data/european_union_27_estonia.rb +0 -74
  34. data/lib/sapor/regional_data/european_union_27_finland.rb +0 -74
  35. data/lib/sapor/regional_data/european_union_27_france.rb +0 -84
  36. data/lib/sapor/regional_data/european_union_27_ireland.rb +0 -96
  37. data/lib/sapor/regional_data/european_union_27_ireland_with_ia.rb +0 -97
  38. data/lib/sapor/regional_data/european_union_27_italy.rb +0 -84
  39. data/lib/sapor/regional_data/european_union_27_netherlands.rb +0 -81
  40. data/lib/sapor/regional_data/european_union_27_poland.rb +0 -84
  41. data/lib/sapor/regional_data/european_union_27_spain.rb +0 -82
  42. data/spec/unit/european_union_27_austria_spec.rb +0 -61
  43. data/spec/unit/european_union_27_croatia_spec.rb +0 -60
  44. data/spec/unit/european_union_27_denmark_spec.rb +0 -62
  45. data/spec/unit/european_union_27_estonia_spec.rb +0 -94
  46. data/spec/unit/european_union_27_finland_spec.rb +0 -75
  47. data/spec/unit/european_union_27_france_spec.rb +0 -73
  48. data/spec/unit/european_union_27_ireland_spec.rb +0 -72
  49. data/spec/unit/european_union_27_ireland_with_ia_spec.rb +0 -74
  50. data/spec/unit/european_union_27_italy_spec.rb +0 -69
  51. data/spec/unit/european_union_27_netherlands_spec.rb +0 -81
  52. data/spec/unit/european_union_27_poland_spec.rb +0 -69
  53. data/spec/unit/european_union_27_spain_spec.rb +0 -130
@@ -1,84 +0,0 @@
1
- # encoding: utf-8
2
- #
3
- # Statistical Analysis of Polling Results (SAPoR)
4
- # Copyright (C) 2020 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
- module Sapor
21
- #
22
- # The regional data for the European Union (27): Italy.
23
- #
24
- class EuropeanUnion27Italy < Area
25
- include Singleton
26
-
27
- def area_code
28
- 'EU27[IT]'
29
- end
30
-
31
- def coalitions
32
- COALITIONS
33
- end
34
-
35
- def no_of_seats
36
- NO_OF_SEATS
37
- end
38
-
39
- def population_size
40
- POPULATION_SIZE
41
- end
42
-
43
- def seats(simulation)
44
- seats = electoral_system.project(simulation)
45
- seats['Südtiroler Volkspartei (EPP)'] = NO_OF_SVP_SEATS
46
- seats['Partito Democratico (S&D)'] -= NO_OF_SVP_SEATS
47
- seats
48
- end
49
-
50
- private
51
-
52
- COALITIONS = [['Azione (S&D)', 'Liberi e Uguali (S&D)',
53
- 'Partito Democratico (S&D)'],
54
- ['Cambiamo! (*)', 'Insieme (*)'],
55
- ['CasaPound Italia (NI)', 'Movimento 5 Stelle (NI)'],
56
- ['Civica Popolare (RE)', 'Italia Viva (RE)',
57
- 'Più Europa (RE)'],
58
- ['Europa Verde (Greens/EFA)'],
59
- ['Forza Italia (EPP)', 'Südtiroler Volkspartei (EPP)'],
60
- ['Fratelli d’Italia (ECR)', 'Noi con l’Italia (ECR)'],
61
- ['Lega Nord (ID)'],
62
- ['Potere al Popolo (GUE/NGL)']].freeze
63
-
64
- NO_OF_SEATS = 76
65
-
66
- NO_OF_SVP_SEATS = 1
67
-
68
- # Voter turnout on 26 May 2019
69
- # Source: Web page with the official results of the elections of 26 May
70
- # 2019, downloaded on 12 June 2019,
71
- # https://en.wikipedia.org/wiki/2019_European_Parliament_election_in_Italy
72
- POPULATION_SIZE = 26_783_732
73
-
74
- THRESHOLD = 0.04
75
-
76
- def electoral_system
77
- if @electoral_system.nil?
78
- @electoral_system = LargestRemainder.new(NO_OF_SEATS, HareQuota,
79
- THRESHOLD)
80
- end
81
- @electoral_system
82
- end
83
- end
84
- end
@@ -1,81 +0,0 @@
1
- # encoding: utf-8
2
- #
3
- # Statistical Analysis of Polling Results (SAPoR)
4
- # Copyright (C) 2020 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
- module Sapor
21
- #
22
- # The regional data for the European Union (27): the Netherlands.
23
- #
24
- class EuropeanUnion27Netherlands < Area
25
- include Singleton
26
-
27
- def area_code
28
- 'EU27[NL]'
29
- end
30
-
31
- def coalitions
32
- COALITIONS
33
- end
34
-
35
- def no_of_seats
36
- NO_OF_SEATS
37
- end
38
-
39
- def population_size
40
- POPULATION_SIZE
41
- end
42
-
43
- def seats(simulation)
44
- electoral_system.project(simulation)
45
- end
46
-
47
- private
48
-
49
- COALITIONS = [['50Plus (EPP)', 'Christen-Democratisch Appèl (EPP)',
50
- 'ChristenUnie (EPP)'],
51
- ['Bij1 (*)', 'DENK (*)', 'Piratenpartij (*)'],
52
- ['Democraten 66 (RE)',
53
- 'Volkspartij voor Vrijheid en Democratie (RE)'],
54
- ['Staatkundig Gereformeerde Partij (ECR)',
55
- 'Forum voor Democratie (ECR)'],
56
- ['GroenLinks (Greens/EFA)'],
57
- ['Partij van de Arbeid (S&D)'],
58
- ['Partij voor de Dieren (GUE/NGL)',
59
- 'Socialistische Partij (GUE/NGL)'],
60
- ['Partij voor de Vrijheid (ID)']].freeze
61
-
62
- NO_OF_SEATS = 29
63
-
64
- # Voter turnout on 23 May 2019
65
- # Source: Web page with the official results of the elections of 23 May
66
- # 2019, downloaded on 13 June 2019,
67
- # https://en.wikipedia.org/wiki/2019_European_Parliament_election_in_the_Netherlands
68
- POPULATION_SIZE = 5_497_813
69
-
70
- THRESHOLD = 1 / NO_OF_SEATS.to_f
71
-
72
- def electoral_system
73
- if @electoral_system.nil?
74
- @electoral_system = SingleDistrictProportional.new(NO_OF_SEATS,
75
- DhondtDenominators,
76
- THRESHOLD)
77
- end
78
- @electoral_system
79
- end
80
- end
81
- end
@@ -1,84 +0,0 @@
1
- # encoding: utf-8
2
- #
3
- # Statistical Analysis of Polling Results (SAPoR)
4
- # Copyright (C) 2020 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
- module Sapor
21
- #
22
- # The regional data for the European Union (27): Poland.
23
- #
24
- class EuropeanUnion27Poland < Area
25
- include Singleton
26
-
27
- def area_code
28
- 'EU27[PL]'
29
- end
30
-
31
- def coalitions
32
- COALITIONS
33
- end
34
-
35
- def no_of_seats
36
- NO_OF_SEATS
37
- end
38
-
39
- def population_size
40
- POPULATION_SIZE
41
- end
42
-
43
- def seats(simulation)
44
- electoral_system.project(simulation)
45
- end
46
-
47
- private
48
-
49
- COALITIONS = [['Konfederacja (NI)', 'KORWiN (NI)', 'Kukiz’15 (NI)'],
50
- ['Koalicja Europejska (EPP)',
51
- 'Koalicja Obywatelska (EPP)',
52
- 'Koalicja Polska (EPP)',
53
- 'Platforma Obywatelska (EPP)',
54
- 'Polskie Stronnictwo Ludowe (EPP)'],
55
- ['Lewica (S&D)',
56
- 'Lewica Razem (S&D)',
57
- 'Sojusz Lewicy Demokratycznej (S&D)',
58
- 'Wiosna (S&D)',
59
- 'Wiosna–Partia Razem (S&D)'],
60
- ['.Nowoczesna (RE)'],
61
- ['Bezpartyjni Samorządowcy (*)'],
62
- ['Prawo i Sprawiedliwość (ECR)',
63
- 'Zjednoczona Prawica (ECR)']].freeze
64
-
65
- NO_OF_SEATS = 52
66
-
67
- # Voter turnout on 26 May 2019
68
- # Source: Web page with the official results of the elections of 26 May
69
- # 2019, downloaded on 25 June 2019,
70
- # https://en.wikipedia.org/wiki/2019_European_Parliament_election_in_Poland
71
- POPULATION_SIZE = 13_647_311
72
-
73
- THRESHOLD = 0.05
74
-
75
- def electoral_system
76
- if @electoral_system.nil?
77
- @electoral_system = SingleDistrictProportional.new(NO_OF_SEATS,
78
- DhondtDenominators,
79
- THRESHOLD)
80
- end
81
- @electoral_system
82
- end
83
- end
84
- end
@@ -1,82 +0,0 @@
1
- # encoding: utf-8
2
- #
3
- # Statistical Analysis of Polling Results (SAPoR)
4
- # Copyright (C) 2020 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
- module Sapor
21
- #
22
- # The regional data for the European Union 27: Spain.
23
- #
24
- class EuropeanUnion27Spain < Area
25
- include Singleton
26
-
27
- def area_code
28
- 'EU27[ES]'
29
- end
30
-
31
- def coalitions
32
- COALITIONS
33
- end
34
-
35
- def no_of_seats
36
- NO_OF_SEATS
37
- end
38
-
39
- def population_size
40
- POPULATION_SIZE
41
- end
42
-
43
- def seats(simulation)
44
- electoral_system.project(simulation)
45
- end
46
-
47
- private
48
-
49
- COALITIONS = [['Ahora Repúblicas (Greens/EFA)',
50
- 'Bloque Nacionalista Galego–Nós Candidatura Galega (Greens/EFA)',
51
- 'Coalició Compromís (Greens/EFA)',
52
- 'Esquerra Republicana de Catalunya–Catalunya Sí (Greens/EFA)',
53
- 'Primavera Europea (Greens/EFA)'],
54
- ['Ciudadanos–Partido de la Ciudadanía (RE)',
55
- 'Coalición Canaria–Partido Nacionalista Canario (RE)',
56
- 'Coalición por Europa (RE)',
57
- 'Euzko Alderdi Jeltzalea/Partido Nacionalista Vasco (RE)'],
58
- ['Euskal Herria Bildu (GUE/NGL)',
59
- 'Partido Animalista Contra el Maltrato Animal (GUE/NGL)',
60
- 'Unidos Podemos (GUE/NGL)'],
61
- ['Partido Popular (EPP)'],
62
- ['Partido Socialista Obrero Español (S&D)'],
63
- ['Partit Demòcrata Europeu Català (NI)'],
64
- ['Vox (ECR)']].freeze
65
-
66
- NO_OF_SEATS = 59
67
-
68
- # Voter turnout on 26 May 2019
69
- # Source: Web page with the official results of the elections of 26 May
70
- # 2019, downloaded on 10 June 2019,
71
- # https://en.wikipedia.org/wiki/2019_European_Parliament_election_in_Spain
72
- POPULATION_SIZE = 22_410_049
73
-
74
- def electoral_system
75
- if @electoral_system.nil?
76
- @electoral_system = SingleDistrictProportional.new(NO_OF_SEATS, \
77
- DhondtDenominators)
78
- end
79
- @electoral_system
80
- end
81
- end
82
- end
@@ -1,61 +0,0 @@
1
- # encoding: utf-8
2
- #
3
- # Statistical Analysis of Polling Results (SAPoR)
4
- # Copyright (C) 2020 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::EuropeanUnion27Austria, '#area_code' do
23
- it 'returns EU27[AT] as the area code' do
24
- expect(Sapor::EuropeanUnion27Austria.instance.area_code).to eq('EU27[AT]')
25
- end
26
- end
27
-
28
- describe Sapor::EuropeanUnion27Austria, '#no_of_seats' do
29
- it 'returns 19 as the number of seats' do
30
- expect(Sapor::EuropeanUnion27Austria.instance.no_of_seats).to eq(19)
31
- end
32
- end
33
-
34
- describe Sapor::EuropeanUnion27Austria, '#population_size' do
35
- it 'returns a population size of 3,834,656' do
36
- expect(Sapor::EuropeanUnion27Austria.instance.population_size).to \
37
- eq(3_834_656)
38
- end
39
- end
40
-
41
- describe Sapor::EuropeanUnion27Austria, '#seats' do
42
- it 'calculates the number of seats for the election of 2019' do
43
- results = { 'Österreichische Volkspartei (EPP)' => 1_305_956,
44
- 'Sozialdemokratische Partei Österreichs (S&D)' => 903_151,
45
- 'Freiheitliche Partei Österreichs (ENF)' => 650_114,
46
- 'Die Grünen–Die Grüne Alternative (Greens/EFA)' => 532_193,
47
- 'NEOS–Das Neue Österreich und Liberales Forum (ALDE)' => \
48
- 319_024,
49
- 'EUROPA JETZT (*)' => 39_087,
50
- 'Kommunistische Partei Österreichs (*)' => 30_087 }
51
- seats = Sapor::EuropeanUnion27Austria.instance.seats(results)
52
- expect(seats['Österreichische Volkspartei (EPP)']).to eq(7)
53
- expect(seats['Sozialdemokratische Partei Österreichs (S&D)']).to eq(5)
54
- expect(seats['Freiheitliche Partei Österreichs (ENF)']).to eq(3)
55
- expect(seats['Die Grünen–Die Grüne Alternative (Greens/EFA)']).to eq(2 + 1)
56
- expect(seats['NEOS–Das Neue Österreich und Liberales Forum (ALDE)']).to \
57
- eq(1)
58
- expect(seats['EUROPA JETZT (*)']).to eq(0)
59
- expect(seats['Kommunistische Partei Österreichs (*)']).to eq(0)
60
- end
61
- end
@@ -1,60 +0,0 @@
1
- # encoding: utf-8
2
- #
3
- # Statistical Analysis of Polling Results (SAPoR)
4
- # Copyright (C) 2020 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::EuropeanUnion27Croatia, '#area_code' do
23
- it 'returns EU27[HR] as the area code' do
24
- expect(Sapor::EuropeanUnion27Croatia.instance.area_code).to \
25
- eq('EU27[HR]')
26
- end
27
- end
28
-
29
- describe Sapor::EuropeanUnion27Croatia, '#no_of_seats' do
30
- it 'returns 12 as the number of seats' do
31
- expect(Sapor::EuropeanUnion27Croatia.instance.no_of_seats).to eq(12)
32
- end
33
- end
34
-
35
- describe Sapor::EuropeanUnion27Croatia, '#population_size' do
36
- it 'returns a population size of 1,073,954' do
37
- expect(Sapor::EuropeanUnion27Croatia.instance.population_size).to \
38
- eq(1_073_954)
39
- end
40
- end
41
-
42
- describe Sapor::EuropeanUnion27Croatia, '#seats' do
43
- it 'calculates the number of seats for the election of 2014' do
44
- results = { 'HDZ-ova koalicija (EPP)' => 381_844,
45
- 'Kukuriku koalicija (S&D)' => 275_904,
46
- 'Održivi razvoj Hrvatske (—)' => 86_806,
47
- 'Savez za Hrvatsku (—)' => 63_437,
48
- 'Hrvatski laburisti–Stranka rada (GUE/NGL)' => 31_363,
49
- 'Partnership of Croatian Center (—)' => 22_098,
50
- 'Others (—)' => 60_452 }
51
- seats = Sapor::EuropeanUnion27Croatia.instance.seats(results)
52
- expect(seats['HDZ-ova koalicija (EPP)']).to eq(6)
53
- expect(seats['Kukuriku koalicija (S&D)']).to eq(4)
54
- expect(seats['Održivi razvoj Hrvatske (—)']).to eq(1)
55
- expect(seats['Savez za Hrvatsku (—)']).to eq(0 + 1)
56
- expect(seats['Hrvatski laburisti–Stranka rada (GUE/NGL)']).to eq(0)
57
- expect(seats['Partnership of Croatian Center (—)']).to eq(0)
58
- expect(seats['Others (—)']).to eq(0)
59
- end
60
- end
@@ -1,62 +0,0 @@
1
- # encoding: utf-8
2
- #
3
- # Statistical Analysis of Polling Results (SAPoR)
4
- # Copyright (C) 2020 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::EuropeanUnion27Denmark, '#area_code' do
23
- it 'returns EU27[DK] as the area code' do
24
- expect(Sapor::EuropeanUnion27Denmark.instance.area_code).to \
25
- eq('EU27[DK]')
26
- end
27
- end
28
-
29
- describe Sapor::EuropeanUnion27Denmark, '#no_of_seats' do
30
- it 'returns 14 as the number of seats' do
31
- expect(Sapor::EuropeanUnion27Denmark.instance.no_of_seats).to eq(14)
32
- end
33
- end
34
-
35
- describe Sapor::EuropeanUnion27Denmark, '#population_size' do
36
- it 'returns a population size of 2,800,029' do
37
- expect(Sapor::EuropeanUnion27Denmark.instance.population_size).to \
38
- eq(2_800_029)
39
- end
40
- end
41
-
42
- describe Sapor::EuropeanUnion27Denmark, '#seats' do
43
- it 'calculates the number of seats for the election of 2014' do
44
- results = { 'Dansk Folkeparti (EFDD)' => 605_766,
45
- 'Socialdemokraterne (S&D)' => 434_894,
46
- 'Venstre (ALDE)' => 378_772,
47
- 'Socialistisk Folkeparti (Greens/EFA)' => 248_244,
48
- 'Det Konservative Folkeparti (EPP)' => 208_067,
49
- 'Folkebevægelsen mod EU (GUE/NGL)' => 183_493,
50
- 'Radikale Venstre (ALDE)' => 148_006,
51
- 'Liberal Alliance (ALDE)' => 65_776 }
52
- seats = Sapor::EuropeanUnion27Denmark.instance.seats(results)
53
- expect(seats['Dansk Folkeparti (EFDD)']).to eq(4)
54
- expect(seats['Socialdemokraterne (S&D)']).to eq(3)
55
- expect(seats['Venstre (ALDE)']).to eq(2 + 1)
56
- expect(seats['Socialistisk Folkeparti (Greens/EFA)']).to eq(1)
57
- expect(seats['Det Konservative Folkeparti (EPP)']).to eq(1)
58
- expect(seats['Folkebevægelsen mod EU (GUE/NGL)']).to eq(1)
59
- expect(seats['Radikale Venstre (ALDE)']).to eq(1)
60
- expect(seats['Liberal Alliance (ALDE)']).to eq(0)
61
- end
62
- end
@@ -1,94 +0,0 @@
1
- # encoding: utf-8
2
- #
3
- # Statistical Analysis of Polling Results (SAPoR)
4
- # Copyright (C) 2020 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::EuropeanUnion27Estonia, '#area_code' do
23
- it 'returns EU27[EE] as the area code' do
24
- expect(Sapor::EuropeanUnion27Estonia.instance.area_code).to \
25
- eq('EU27[EE]')
26
- end
27
- end
28
-
29
- describe Sapor::EuropeanUnion27Estonia, '#no_of_seats' do
30
- it 'returns 7 as the number of seats' do
31
- expect(Sapor::EuropeanUnion27Estonia.instance.no_of_seats).to eq(7)
32
- end
33
- end
34
-
35
- describe Sapor::EuropeanUnion27Estonia, '#population_size' do
36
- it 'returns a population size of 332,859' do
37
- expect(Sapor::EuropeanUnion27Estonia.instance.population_size).to \
38
- eq(332_859)
39
- end
40
- end
41
-
42
- describe Sapor::EuropeanUnion27Estonia, '#seats' do
43
- it 'calculates the number of seats for the election of 2014' do
44
- results = { 'Eesti Reformierakond (ALDE)' => 79_849,
45
- 'Eesti Keskerakond (ALDE)' => 73_419,
46
- 'Isamaa ja Res Publica Liit (EPP)' => 45_765,
47
- 'Sotsiaaldemokraatlik Erakond (S&D)' => 44_550,
48
- 'INDREK TARAND (Greens/EFA)' => 43_369,
49
- 'Eesti Konservatiivne Rahvaerakond (NI)' => 13_247,
50
- 'TANEL TALVE (*)' => 10_073,
51
- 'SILVER MEIKAR (*)' => 6018,
52
- 'Eesti Iseseisvuspartei (*)' => 4158,
53
- 'KRISTIINA OJULAND (*)' => 3024,
54
- 'KRISTA MULENOK (*)' => 1266,
55
- 'Erakond Eestimaa Rohelised (Greens/EFA)' => 986,
56
- 'RENE KUULMANN (*)' => 632,
57
- 'JEVGENI KRIŠTAFOVITŠ (*)' => 594,
58
- 'IMRE MÜRK (*)' => 330,
59
- 'OLGA SÕTNIK (*)' => 328,
60
- 'Eestimaa Ühendatud Vasakpartei (*)' => 226,
61
- 'SVETLANA IVNITSKAJA (*)' => 167,
62
- 'TAIRA AASA (*)' => 126,
63
- 'ROMAN UBAKIVI (*)' => 96,
64
- 'DMITRI SILBER (*)' => 86,
65
- 'ANDRES INN (*)' => 72,
66
- 'LANCE GARETH EDWARD BOXALL (*)' => 64,
67
- 'JOERI WIERSMA (*)' => 48 }
68
- seats = Sapor::EuropeanUnion27Estonia.instance.seats(results)
69
- expect(seats['Eesti Reformierakond (ALDE)']).to eq(2)
70
- expect(seats['Eesti Keskerakond (ALDE)']).to eq(1 + 1)
71
- expect(seats['Isamaa ja Res Publica Liit (EPP)']).to eq(1)
72
- expect(seats['Sotsiaaldemokraatlik Erakond (S&D)']).to eq(1)
73
- expect(seats['INDREK TARAND (Greens/EFA)']).to eq(1)
74
- expect(seats['Eesti Konservatiivne Rahvaerakond (NI)']).to eq(0)
75
- expect(seats['TANEL TALVE (*)']).to eq(0)
76
- expect(seats['SILVER MEIKAR (*)']).to eq(0)
77
- expect(seats['Eesti Iseseisvuspartei (*)']).to eq(0)
78
- expect(seats['KRISTIINA OJULAND (*)']).to eq(0)
79
- expect(seats['KRISTA MULENOK (*)']).to eq(0)
80
- expect(seats['Erakond Eestimaa Rohelised (Greens/EFA)']).to eq(0)
81
- expect(seats['RENE KUULMANN (*)']).to eq(0)
82
- expect(seats['JEVGENI KRIŠTAFOVITŠ (*)']).to eq(0)
83
- expect(seats['IMRE MÜRK (*)']).to eq(0)
84
- expect(seats['OLGA SÕTNIK (*)']).to eq(0)
85
- expect(seats['Eestimaa Ühendatud Vasakpartei (*)']).to eq(0)
86
- expect(seats['SVETLANA IVNITSKAJA (*)']).to eq(0)
87
- expect(seats['TAIRA AASA (*)']).to eq(0)
88
- expect(seats['ROMAN UBAKIVI (*)']).to eq(0)
89
- expect(seats['DMITRI SILBER (*)']).to eq(0)
90
- expect(seats['ANDRES INN (*)']).to eq(0)
91
- expect(seats['LANCE GARETH EDWARD BOXALL (*)']).to eq(0)
92
- expect(seats['JOERI WIERSMA (*)']).to eq(0)
93
- end
94
- end
@@ -1,75 +0,0 @@
1
- # encoding: utf-8
2
- #
3
- # Statistical Analysis of Polling Results (SAPoR)
4
- # Copyright (C) 2020 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::EuropeanUnion27Finland, '#area_code' do
23
- it 'returns EU27[FI] as the area code' do
24
- expect(Sapor::EuropeanUnion27Finland.instance.area_code).to eq('EU27[FI]')
25
- end
26
- end
27
-
28
- describe Sapor::EuropeanUnion27Finland, '#no_of_seats' do
29
- it 'returns 14 as the number of seats' do
30
- expect(Sapor::EuropeanUnion27Finland.instance.no_of_seats).to eq(14)
31
- end
32
- end
33
-
34
- describe Sapor::EuropeanUnion27Finland, '#population_size' do
35
- it 'returns a population size of 1,830,045' do
36
- expect(Sapor::EuropeanUnion27Finland.instance.population_size).to \
37
- eq(1_830_045)
38
- end
39
- end
40
-
41
- describe Sapor::EuropeanUnion27Finland, '#seats' do
42
- it 'calculates the number of seats using the votes of the 2014 election' do
43
- results = { 'Kansallinen Kokoomus (EPP)' => 390_376,
44
- 'Suomen Keskusta (ALDE)' => 339_895,
45
- 'Perussuomalaiset (EFDD)' => 222_457,
46
- 'Suomen Sosialidemokraattinen Puolue (S&D)' => 212_781,
47
- 'Vihreä liitto (Greens/EFA)' => 161_263,
48
- 'Vasemmistoliitto (GUE/NGL)' => 161_074,
49
- 'Svenska folkpartiet i Finland (ALDE)' => 116_747,
50
- 'Kristillisdemokraatit (EPP)' => 90_586,
51
- 'Piraattipuolue (Greens/EFA)' => 12_378,
52
- 'Suomen Kommunistinen Puolue (GUE/NGL)' => 5_932,
53
- 'Itsenäisyyspuolue (—)' => 5_668,
54
- 'Muutos 2011 (—)' => 4_768,
55
- 'Köyhien Asialla (—)' => 2_667,
56
- 'Sinivalkoinen Rintama (—)' => 1_176,
57
- 'Kristiina Ilmarinen (—)' => 526 }
58
- seats = Sapor::EuropeanUnion27Finland.instance.seats(results)
59
- expect(seats['Kansallinen Kokoomus (EPP)']).to eq(3 + 1)
60
- expect(seats['Suomen Keskusta (ALDE)']).to eq(3)
61
- expect(seats['Perussuomalaiset (EFDD)']).to eq(2)
62
- expect(seats['Suomen Sosialidemokraattinen Puolue (S&D)']).to eq(2)
63
- expect(seats['Vihreä liitto (Greens/EFA)']).to eq(1)
64
- expect(seats['Vasemmistoliitto (GUE/NGL)']).to eq(1)
65
- expect(seats['Svenska folkpartiet i Finland (ALDE)']).to eq(1)
66
- expect(seats['Kristillisdemokraatit (EPP)']).to eq(0)
67
- expect(seats['Piraattipuolue (Greens/EFA)']).to eq(0)
68
- expect(seats['Suomen Kommunistinen Puolue (GUE/NGL)']).to eq(0)
69
- expect(seats['Itsenäisyyspuolue (—)']).to eq(0)
70
- expect(seats['Muutos 2011 (—)']).to eq(0)
71
- expect(seats['Köyhien Asialla (—)']).to eq(0)
72
- expect(seats['Sinivalkoinen Rintama (—)']).to eq(0)
73
- expect(seats['Kristiina Ilmarinen (—)']).to eq(0)
74
- end
75
- end