Skip to content

Commit 4702455

Browse files
authored
Merge pull request #1010 from Axelrod-Python/transformers_docstring
Ensure that transformers do not overwrite docstrings
2 parents cb3bccc + 0a315bc commit 4702455

File tree

6 files changed

+13
-5
lines changed

6 files changed

+13
-5
lines changed

axelrod/strategies/gradualkiller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class GradualKiller(Player):
1717
1818
Names
1919
20-
- Gradual Killer: [PRISON1998]_
20+
- Gradual Killer: [Prison1998]_
2121
"""
2222

2323
# These are various properties for the strategy

axelrod/strategies/stalker.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@
1010
@FinalTransformer((D), name_prefix=None) # End with defection
1111
class Stalker(Player):
1212
"""
13+
1314
This is a strategy which is only influenced by the score.
1415
Its behavior is based on three values:
1516
the very_bad_score (all rounds in defection)
1617
very_good_score (all rounds in cooperation)
1718
wish_score (average between bad and very_good score)
1819
1920
It starts with cooperation.
21+
2022
- If current_average_score > very_good_score, it defects
2123
- If current_average_score lies in (wish_score, very_good_score) it
2224
cooperates

axelrod/strategy_transformers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ def __repr__(self):
150150
"__repr__": __repr__,
151151
"__module__": PlayerClass.__module__,
152152
"classifier": classifier,
153+
"__doc__": PlayerClass.__doc__,
153154
})
154155
return new_class
155156
return Decorator

axelrod/tests/unit/test_strategy_transformers.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ def test_repr(self):
5353
self.assertEqual(str(MixedTransformer(0.3, (axelrod.Alternator, axelrod.Bully))(axelrod.Random)(0.1)),
5454
"Mutated Random: 0.1: 0.3, ['Alternator', 'Bully']")
5555

56+
def test_doc(self):
57+
"""Test that the original docstring is present"""
58+
player = axelrod.Alternator()
59+
transformer = InitialTransformer([D, D, C])(axelrod.Alternator)()
60+
self.assertEqual(player.__doc__, transformer.__doc__)
61+
5662
def test_cloning(self):
5763
"""Tests that Player.clone preserves the application of transformations.
5864
"""

docs/reference/bibliography.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@ documentation.
2222
.. [Bendor1993] Bendor, Jonathan, et al. “Cooperation Under Uncertainty: What Is New, What Is True, and What Is Important.” American Sociological Review, vol. 61, no. 2, 1996, pp. 333–338., www.jstor.org/stable/2096337.
2323
.. [Beaufils1997] Beaufils, B. and Delahaye, J. (1997). Our Meeting With Gradual: A Good Strategy For The Iterated Prisoner’s Dilemma. http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.42.4041
2424
.. [Berg2015] Berg, P. Van Den, & Weissing, F. J. (2015). The importance of mechanisms for the evolution of cooperation. Proceedings of the Royal Society B-Biological Sciences, 282.
25-
.. [Flood1958] Merrill M. Flood. Some Experimental Games, 1958.
2625
.. [Frean1994] Frean, Marcus R. “The Prisoner's Dilemma without Synchrony.” Proceedings: Biological Sciences, vol. 257, no. 1348, 1994, pp. 75–79. www.jstor.org/stable/50253.
2726
.. [Hilde2013] Hilbe, C., Nowak, M.A. and Traulsen, A. (2013). Adaptive dynamics of extortion and compliance, PLoS ONE, 8(11), p. e77886. doi: 10.1371/journal.pone.0077886.
2827
.. [Kraines1989] Kraines, D. & Kraines, V. Theor Decis (1989) 26: 47. doi:10.1007/BF00134056
29-
.. [LessWrong2011] Zoo of Strategies (2011) LessWrong. Available at: http://lesswrong.com/lw/7f2/prisoners_dilemma_tournament_results/
28+
.. [LessWrong2011] Zoo of Strategies (2011) LessWrong. Available at: http://lesswrong.com/lw/7f2/prisoners_dilemma_tournament_results/
3029
.. [Li2009] Li, J. & Kendall, G. (2009). A Strategy with Novel Evolutionary Features for the Iterated Prisoner’s Dilemma. Evolutionary Computation 17(2): 257–274.
3130
.. [Li2011] Li, J., Hingston, P., Member, S., & Kendall, G. (2011). Engineering Design of Strategies for Winning Iterated Prisoner ’ s Dilemma Competitions, 3(4), 348–360.
3231
.. [Li2016] Li, J. and Kendall, G. (2016). The Effect of Memory Size on the Evolutionary Stability of Strategies in Iterated Prisoner's Dilemma. IEEE Transactions on Evolutionary Computation, 18(6) 819-826
@@ -43,5 +42,5 @@ documentation.
4342
.. [Shakarian2013] Shakarian, P., Roos, P. & Moores, G. A Novel Analytical Method for Evolutionary Graph Theory Problems.
4443
.. [Slany2007] Slany W. and Kienreich W., On some winning strategies for the iterated prisoner’s dilemma, in Kendall G., Yao X. and Chong S. (eds.) The iterated prisoner’s dilemma: 20 years on. World Scientific, chapter 8, pp. 171-204, 2007.
4544
.. [Stewart2012] Stewart, a. J., & Plotkin, J. B. (2012). Extortion and cooperation in the Prisoner’s Dilemma. Proceedings of the National Academy of Sciences, 109(26), 10134–10135. http://doi.org/10.1073/pnas.1208087109
46-
.. [Szabó1992] Szabó, G., & Fáth, G. (2007). Evolutionary games on graphs. Physics Reports, 446(4-6), 97–216. http://doi.org/10.1016/j.physrep.2007.04.004
45+
.. [Szabo2007] Szabó, G., & Fáth, G. (2007). Evolutionary games on graphs. Physics Reports, 446(4-6), 97–216. http://doi.org/10.1016/j.physrep.2007.04.004
4746
.. [Tzafestas2000] Tzafestas, E. (2000). Toward adaptive cooperative behavior. From Animals to Animals: Proceedings of the 6th International Conference on the Simulation of Adaptive Behavior {(SAB-2000)}, 2, 334–340.

docs/tutorials/further_topics/spatial_tournaments.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ and edges define whether or not a given player pair will have a match.
77
The initial work on spatial tournaments was done by Nowak and May in a 1992
88
paper: [Nowak1992]_.
99

10-
Additionally, Szabó and Fáth in their 2007 paper [Szabó1992]_ consider a variety
10+
Additionally, Szabó and Fáth in their 2007 paper [Szabo2007]_ consider a variety
1111
of graphs, such as lattices, small world, scale-free graphs and evolving
1212
networks.
1313

0 commit comments

Comments
 (0)