Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Liquid Majority Judgment
Limaju CLI Python
Commits
1967c6dc
Commit
1967c6dc
authored
Jan 14, 2020
by
Dominique Merle
💬
Browse files
Improve the merit profiles graph.
Peer-session ! \o/ IOTH Going to watch Steven's birthdays now.
parent
e619d18f
Changes
3
Hide whitespace changes
Inline
Side-by-side
limaju/examples/judgments_02.csv
View file @
1967c6dc
...
...
@@ -13,3 +13,7 @@ Timestamp,Tyran Sanguinaire,Chien,Écologiste Décroissant,Capitaliste Prédateu
12/9/2019 11:36:07,à rejeter,passable,assez bien,à rejeter,très bien,passable,insuffisant⋅e,assez bien,bien
12/10/2019 5:33:59,à rejeter,à rejeter,excellent⋅e,à rejeter,à rejeter,à rejeter,à rejeter,excellent⋅e,assez bien
12/10/2019 13:50:28,à rejeter,à rejeter,bien,à rejeter,assez bien,à rejeter,à rejeter,bien,insuffisant⋅e
12/14/2019 1:50:11,à rejeter,excellent⋅e,très bien,à rejeter,insuffisant⋅e,insuffisant⋅e,à rejeter,insuffisant⋅e,passable
1/8/2020 19:52:54,à rejeter,passable,bien,insuffisant⋅e,très bien,passable,insuffisant⋅e,très bien,passable
1/9/2020 0:09:48,à rejeter,à rejeter,excellent⋅e,à rejeter,très bien,à rejeter,à rejeter,très bien,bien
1/11/2020 18:09:23,à rejeter,à rejeter,,à rejeter,passable,à rejeter,à rejeter,insuffisant⋅e,assez bien
limaju/limaju.py
View file @
1967c6dc
...
...
@@ -292,11 +292,11 @@ def plot_merit_profile(judgments_tallies, candidates, mentions, filename=None):
:param filename: String, should match `*.png` or `*.pdf`. Paths are allowed.
"""
pprint
(
judgments_tallies
)
pprint
(
"candidates"
)
pprint
(
candidates
)
pprint
(
"mentions"
)
pprint
(
mentions
)
#
pprint(judgments_tallies)
#
pprint("candidates")
#
pprint(candidates)
#
pprint("mentions")
#
pprint(mentions)
bar_girth
=
0.62
candidates
=
[
c
for
c
in
reversed
(
candidates
)]
# :(|) oOoK
...
...
@@ -350,6 +350,7 @@ def plot_merit_profile(judgments_tallies, candidates, mentions, filename=None):
# vlorp = 0.05
barhs
=
[]
legends
=
[]
separators
=
[]
ind
=
[
i
for
i
in
range
(
candidates_amount
)]
leftOffset
=
(
0
,)
*
candidates_amount
judgments_sum
=
(
0
,)
*
candidates_amount
...
...
@@ -358,7 +359,7 @@ def plot_merit_profile(judgments_tallies, candidates, mentions, filename=None):
judgments_sum
=
tuple
(
p
+
q
for
p
,
q
in
zip
(
opinion
,
judgments_sum
))
judgments_count
=
max
(
judgments_sum
)
vlorp
=
judgments_count
*
0.003
vlorp
=
judgments_count
*
0.003
*
0
for
i
,
mention
in
enumerate
(
mentions
):
#print(u"Plotting bars of mention %s…" % mention)
...
...
@@ -366,9 +367,17 @@ def plot_merit_profile(judgments_tallies, candidates, mentions, filename=None):
barh
=
plt
.
barh
(
ind
,
opinion
,
bar_girth
,
left
=
leftOffset
,
color
=
colors
[
i
])
barhs
.
append
(
barh
)
legends
.
append
(
barh
[
0
])
if
i
>
0
:
for
j
,
offset
in
enumerate
(
leftOffset
):
separators
.
append
([
(
offset
,
j
-
0.5
),
(
offset
,
j
+
0.5
),
])
# At some point, we should either go full numpy or not at all
# The vlorp is a nasty hack to show white separators between colors
leftOffset
=
tuple
(
p
+
q
+
vlorp
for
p
,
q
in
zip
(
opinion
,
leftOffset
))
leftOffset
=
tuple
(
p
+
q
+
(
vlorp
if
p
else
0
)
for
p
,
q
in
zip
(
opinion
,
leftOffset
))
# p1 = plt.barh(ind, menMeans, bar_girth)
# p2 = plt.barh(ind, womenMeans, bar_girth, left=menMeans)
...
...
@@ -392,6 +401,17 @@ def plot_merit_profile(judgments_tallies, candidates, mentions, filename=None):
bbox_to_anchor
=
(
0.5
,
-
0.15
),
)
from
matplotlib.collections
import
LineCollection
# lines = [[(10.0,1.0), (0.0,0.0)]]
lc
=
LineCollection
(
separators
,
colors
=
((
1
,
1
,
1
,
1
),),
linewidths
=
2
,
)
# fig, ax = plt.subplots()
# ax.add_collection(lc)
plt
.
gca
().
add_collection
(
lc
)
plt
.
axvline
(
x
=
adjusted_width
*
0.5
,
linestyle
=
'--'
)
# ax.legend(loc='upper center', bbox_to_anchor=(0.5, -0.05, fancybox=True, shadow=True, ncol=5)
...
...
limaju/test_limaju.py
View file @
1967c6dc
...
...
@@ -69,8 +69,7 @@ EXCELLENT, EXCELLENT, EXCELLENT, EXCELLENT
self
.
assertEqual
(
deliberation
,
[
'B'
,
'D'
,
'A'
,
'C'
])
def
test_plotting_deliberation
(
self
):
def
test_plotting_deliberation_with_merit_profiles
(
self
):
mentions
=
load_mentions_from_string
(
self
.
test_mentions
)
judgments
=
''
with
open
(
"examples/judgments_01.csv"
)
as
sample
:
...
...
@@ -78,8 +77,25 @@ EXCELLENT, EXCELLENT, EXCELLENT, EXCELLENT
deliberation
,
tally
=
deliberate
(
judgments
,
self
.
test_mentions
)
plot_merit_profile
(
tally
,
deliberation
,
mentions
,
filename
=
"test_plot.png"
)
# self.assertEqual(deliberation, ['B', 'D', 'A', 'C'])
def
test_plotting_deliberation_02_with_merit_profiles
(
self
):
# mentions = load_mentions_from_string(self.test_mentions)
mentions
=
(
u
"excellent⋅e"
,
u
"très bien"
,
u
"bien"
,
u
"assez bien"
,
u
"passable"
,
u
"insuffisant⋅e"
,
u
"à rejeter"
,
)
judgments
=
''
with
open
(
"examples/judgments_02.csv"
)
as
sample
:
judgments
=
""
.
join
(
sample
.
readlines
())
deliberation
,
tally
=
deliberate
(
judgments
,
mentions
,
skip_cols
=
1
)
filename
=
"merit_profiles_02.png"
plot_merit_profile
(
tally
,
deliberation
,
mentions
,
filename
=
filename
)
# def test_raise(self):
# with self.assertRaises(TypeError):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment