Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add game_theory.normal_form_game #220

Merged
merged 6 commits into from
Jan 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 37 additions & 12 deletions docs/qe_apidoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
Examples
--------
$ python qe_apidoc.py # generates the two separate directories
$ python qe_apidoc.py foo_bar # generates the two separate directories
$ python qe_apidoc.py foo_bar # generates the two separate directories
$ python qe_apidoc.py single # generates the single directory


Expand Down Expand Up @@ -49,6 +49,15 @@
:show-inheritance:
"""

game_theory_module_template = """{mod_name}
{equals}

.. automodule:: quantecon.game_theory.{mod_name}
:members:
:undoc-members:
:show-inheritance:
"""

markov_module_template = """{mod_name}
{equals}

Expand Down Expand Up @@ -101,10 +110,10 @@
=======================

The `quantecon` python library consists of a number of modules which
includes economic models (models), markov chains (markov), random
generation utilities (random), a collection of tools (tools),
and other utilities (util) which are
mainly used by developers internal to the package.
includes economic models (models), markov chains (markov), random
generation utilities (random), a collection of tools (tools),
and other utilities (util) which are
mainly used by developers internal to the package.

The models section, for example, contains implementations of standard
models, many of which are discussed in lectures on the website `quant-
Expand All @@ -113,6 +122,7 @@
.. toctree::
:maxdepth: 2

game_theory
markov
random
tools
Expand Down Expand Up @@ -173,6 +183,12 @@ def all_auto():


def model_tool():
# list file names with game_theory
game_theory_files = glob("../quantecon/game_theory/[a-z0-9]*.py")
game_theory = list(map(lambda x: x.split('/')[-1][:-3], game_theory_files))
# Alphabetize
game_theory.sort()

# list file names with markov
markov_files = glob("../quantecon/markov/[a-z0-9]*.py")
markov = list(map(lambda x: x.split('/')[-1][:-3], markov_files))
Expand All @@ -191,23 +207,30 @@ def model_tool():
# Alphabetize
tools.remove("version")
tools.sort()

# list file names of utilities
util_files = glob("../quantecon/util/[a-z0-9]*.py")
util = list(map(lambda x: x.split('/')[-1][:-3], util_files))
# Alphabetize
util.sort()

for folder in ["markov","random","tools","util"]:
for folder in ["game_theory", "markov", "random", "tools", "util"]:
if not os.path.exists(source_join(folder)):
os.makedirs(source_join(folder))

# Write file for each game_theory file
for mod in game_theory:
new_path = os.path.join("source", "game_theory", mod + ".rst")
with open(new_path, "w") as f:
equals = "=" * len(mod)
f.write(game_theory_module_template.format(mod_name=mod, equals=equals))

# Write file for each markov file
for mod in markov:
new_path = os.path.join("source", "markov", mod + ".rst")
with open(new_path, "w") as f:
equals = "=" * len(mod)
f.write(markov_module_template.format(mod_name=mod, equals=equals))
f.write(markov_module_template.format(mod_name=mod, equals=equals))

# Write file for each random file
for mod in random:
Expand All @@ -234,18 +257,20 @@ def model_tool():
with open(source_join("index.rst"), "w") as index:
index.write(split_index_template)

gt = "game_theory/" + "\n game_theory/".join(game_theory)
mark = "markov/" + "\n markov/".join(markov)
rand = "random/" + "\n random/".join(random)
tlz = "tools/" + "\n tools/".join(tools)
utls = "util/" + "\n util/".join(util)
#-TocTree-#
toc_tree_list = {"markov":mark,
toc_tree_list = {"game_theory": gt,
"markov": mark,
"tools": tlz,
"random":rand,
"util":utls,
"random": rand,
"util": utls,
}

for f_name in ("markov","random","tools","util"):
for f_name in ("game_theory", "markov", "random", "tools", "util"):
with open(source_join(f_name + ".rst"), "w") as f:
temp = split_file_template.format(name=f_name.capitalize(),
equals="="*len(f_name),
Expand Down
7 changes: 7 additions & 0 deletions docs/source/game_theory.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Game_theory
===========

.. toctree::
:maxdepth: 2

game_theory/normal_form_game
7 changes: 7 additions & 0 deletions docs/source/game_theory/normal_form_game.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
normal_form_game
================

.. automodule:: quantecon.game_theory.normal_form_game
:members:
:undoc-members:
:show-inheritance:
9 changes: 5 additions & 4 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ QuantEcon documentation
=======================

The `quantecon` python library consists of a number of modules which
includes economic models (models), markov chains (markov), random
generation utilities (random), a collection of tools (tools),
and other utilities (util) which are
mainly used by developers internal to the package.
includes economic models (models), markov chains (markov), random
generation utilities (random), a collection of tools (tools),
and other utilities (util) which are
mainly used by developers internal to the package.

The models section, for example, contains implementations of standard
models, many of which are discussed in lectures on the website `quant-
Expand All @@ -15,6 +15,7 @@ econ.net <http://quant-econ.net>`_.
.. toctree::
:maxdepth: 2

game_theory
markov
random
tools
Expand Down
6 changes: 4 additions & 2 deletions quantecon/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#-Modules-#
from . import distributions
from . import game_theory
from . import quad
from . import random

Expand All @@ -17,6 +18,7 @@
from .discrete_rv import DiscreteRV
from .ecdf import ECDF
from .estspec import smooth, periodogram, ar_periodogram
# from .game_theory import <objects-here> #Place Holder if we wish to promote any general objects to the qe namespace.
from .graph_tools import DiGraph
from .gridtools import cartesian, mlinspace
from .kalman import Kalman
Expand All @@ -28,8 +30,8 @@
from .matrix_eqn import solve_discrete_lyapunov, solve_discrete_riccati
from .quadsums import var_quadratic_sum, m_quadratic_sum
#->Propose Delete From Top Level
from .markov import MarkovChain, random_markov_chain, random_stochastic_matrix, gth_solve, tauchen #Promote to keep current examples working
from .markov import mc_compute_stationary, mc_sample_path #Imports that Should be Deprecated with markov package
from .markov import MarkovChain, random_markov_chain, random_stochastic_matrix, gth_solve, tauchen #Promote to keep current examples working
from .markov import mc_compute_stationary, mc_sample_path #Imports that Should be Deprecated with markov package
#<-
from .rank_nullspace import rank_est, nullspace
from .robustlq import RBLQ
Expand Down
6 changes: 6 additions & 0 deletions quantecon/game_theory/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""
Game Theory SubPackage

"""
from .normal_form_game import Player, NormalFormGame
from .normal_form_game import pure2mixed, best_response_2p
Loading