kopia lustrzana https://github.com/crflynn/voting
apply black elsewhere
rodzic
c80381cd90
commit
8126450e67
57
docs/conf.py
57
docs/conf.py
|
@ -26,7 +26,7 @@ import os
|
|||
import sys
|
||||
|
||||
|
||||
sys.path.insert(0, os.path.abspath('..'))
|
||||
sys.path.insert(0, os.path.abspath(".."))
|
||||
|
||||
import voting
|
||||
|
||||
|
@ -40,22 +40,19 @@ import voting
|
|||
# Add any Sphinx extension module names here, as strings. They can be
|
||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||
# ones.
|
||||
extensions = [
|
||||
'sphinx.ext.autodoc',
|
||||
'sphinx.ext.mathjax',
|
||||
'sphinx.ext.viewcode']
|
||||
extensions = ["sphinx.ext.autodoc", "sphinx.ext.mathjax", "sphinx.ext.viewcode"]
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
templates_path = ["_templates"]
|
||||
|
||||
# The suffix(es) of source filenames.
|
||||
# You can specify multiple suffix as a list of string:
|
||||
#
|
||||
# source_suffix = ['.rst', '.md']
|
||||
source_suffix = '.rst'
|
||||
source_suffix = ".rst"
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'index'
|
||||
master_doc = "index"
|
||||
|
||||
# General information about the project.
|
||||
project = voting.__title__
|
||||
|
@ -67,9 +64,9 @@ author = voting.__author__
|
|||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = ''
|
||||
version = ""
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = ''
|
||||
release = ""
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
|
@ -81,10 +78,10 @@ language = None
|
|||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
# This patterns also effect to html_static_path and html_extra_path
|
||||
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
|
||||
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'sphinx'
|
||||
pygments_style = "sphinx"
|
||||
|
||||
# If true, `todo` and `todoList` produce output, else they produce nothing.
|
||||
todo_include_todos = False
|
||||
|
@ -110,25 +107,20 @@ html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
|
|||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ['_static']
|
||||
html_static_path = ["_static"]
|
||||
|
||||
# Custom sidebar templates, must be a dictionary that maps document names
|
||||
# to template names.
|
||||
#
|
||||
# This is required for the alabaster theme
|
||||
# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
|
||||
html_sidebars = {
|
||||
'**': [
|
||||
'relations.html', # needs 'show_related': True theme option to display
|
||||
'searchbox.html',
|
||||
]
|
||||
}
|
||||
html_sidebars = {"**": ["relations.html", "searchbox.html"]} # needs 'show_related': True theme option to display
|
||||
|
||||
|
||||
# -- Options for HTMLHelp output ------------------------------------------
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'votingdoc'
|
||||
htmlhelp_basename = "votingdoc"
|
||||
|
||||
|
||||
# -- Options for LaTeX output ---------------------------------------------
|
||||
|
@ -137,15 +129,12 @@ latex_elements = {
|
|||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#
|
||||
# 'papersize': 'letterpaper',
|
||||
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#
|
||||
# 'pointsize': '10pt',
|
||||
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#
|
||||
# 'preamble': '',
|
||||
|
||||
# Latex figure (float) alignment
|
||||
#
|
||||
# 'figure_align': 'htbp',
|
||||
|
@ -154,20 +143,14 @@ latex_elements = {
|
|||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title,
|
||||
# author, documentclass [howto, manual, or own class]).
|
||||
latex_documents = [
|
||||
(master_doc, 'voting.tex', 'voting Documentation',
|
||||
'Christopher Flynn', 'manual'),
|
||||
]
|
||||
latex_documents = [(master_doc, "voting.tex", "voting Documentation", "Christopher Flynn", "manual")]
|
||||
|
||||
|
||||
# -- Options for manual page output ---------------------------------------
|
||||
|
||||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
(master_doc, 'voting', 'voting Documentation',
|
||||
[author], 1)
|
||||
]
|
||||
man_pages = [(master_doc, "voting", "voting Documentation", [author], 1)]
|
||||
|
||||
|
||||
# -- Options for Texinfo output -------------------------------------------
|
||||
|
@ -176,7 +159,13 @@ man_pages = [
|
|||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
(master_doc, 'voting', 'voting Documentation',
|
||||
author, 'voting', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
(
|
||||
master_doc,
|
||||
"voting",
|
||||
"voting Documentation",
|
||||
author,
|
||||
"voting",
|
||||
"One line description of project.",
|
||||
"Miscellaneous",
|
||||
)
|
||||
]
|
||||
|
|
|
@ -36,52 +36,75 @@ from voting.quota import hagenbach_bischoff as hb # dupe of apportionment
|
|||
from voting.quota import hare
|
||||
from voting.quota import imperiali
|
||||
|
||||
|
||||
@pytest.fixture(params=[[2560, 3315, 995, 5012]])
|
||||
def votes(request):
|
||||
return request.param
|
||||
|
||||
|
||||
@pytest.fixture(params=[20])
|
||||
def seats(request):
|
||||
return request.param
|
||||
|
||||
|
||||
@pytest.fixture(params=list(range(4, 50)))
|
||||
def seats_val(request):
|
||||
return request.param
|
||||
|
||||
|
||||
@pytest.fixture(params=[[5, 6, 7, 8]])
|
||||
def seats_list(request):
|
||||
return request.param
|
||||
|
||||
@pytest.fixture(params=[adams, dhondt, hagenbach_bischoff, hamilton,
|
||||
huntington_hill, jefferson, sainte_lague, vinton, webster
|
||||
])
|
||||
|
||||
@pytest.fixture(
|
||||
params=[adams, dhondt, hagenbach_bischoff, hamilton, huntington_hill, jefferson, sainte_lague, vinton, webster]
|
||||
)
|
||||
def apportionment_method(request):
|
||||
return request.param
|
||||
|
||||
@pytest.fixture(params=[droop, hb, hare, imperiali])
|
||||
def quota_method(request):
|
||||
return request.param
|
||||
|
||||
@pytest.fixture(params=[droop, hb, hare, imperiali])
|
||||
def quota_method(request):
|
||||
return request.param
|
||||
|
||||
@pytest.fixture(params=[adjusted_loosemore_hanby, dh, gallagher, grofman,
|
||||
least_square, lijphart, loosemore_hanby, rae, regression, rose, sl
|
||||
])
|
||||
|
||||
@pytest.fixture(params=[droop, hb, hare, imperiali])
|
||||
def quota_method(request):
|
||||
return request.param
|
||||
|
||||
|
||||
@pytest.fixture(
|
||||
params=[
|
||||
adjusted_loosemore_hanby,
|
||||
dh,
|
||||
gallagher,
|
||||
grofman,
|
||||
least_square,
|
||||
lijphart,
|
||||
loosemore_hanby,
|
||||
rae,
|
||||
regression,
|
||||
rose,
|
||||
sl,
|
||||
]
|
||||
)
|
||||
def proportion_method(request):
|
||||
return request.param
|
||||
|
||||
@pytest.fixture(params=['seats', 'votes', 'something_else'])
|
||||
|
||||
@pytest.fixture(params=["seats", "votes", "something_else"])
|
||||
def parties(request):
|
||||
return request.param
|
||||
|
||||
@pytest.fixture(params=[berger_parker, general, gini_simpson, golosov,
|
||||
inverse_simpson, laakso_taagepera, renyi, shannon, simpson
|
||||
])
|
||||
|
||||
@pytest.fixture(
|
||||
params=[berger_parker, general, gini_simpson, golosov, inverse_simpson, laakso_taagepera, renyi, shannon, simpson]
|
||||
)
|
||||
def diversity_method(request):
|
||||
return request.param
|
||||
|
||||
|
||||
@pytest.fixture(params=[0, 0.5, 1, 2])
|
||||
def q(request):
|
||||
return request.param
|
||||
|
|
|
@ -8,8 +8,9 @@ from voting.proportion import grofman
|
|||
def test_proportion_method(proportion_method, votes, seats_list):
|
||||
assert proportion_method(votes, seats_list) > 0
|
||||
|
||||
|
||||
def test_grofman_parties(votes, seats_list, parties):
|
||||
if parties not in ('votes', 'seats'):
|
||||
if parties not in ("votes", "seats"):
|
||||
with pytest.raises(ValueError):
|
||||
grofman(votes, seats_list, parties)
|
||||
else:
|
||||
|
|
Ładowanie…
Reference in New Issue