Skip to content

Commit

Permalink
COMPAT: Restored multimethod
Browse files Browse the repository at this point in the history
  • Loading branch information
albop committed Mar 7, 2020
1 parent 3d24936 commit 2296a08
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
15 changes: 11 additions & 4 deletions dolo/algos/ergodic.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import numpy as np

# doesn't seem to support keyword arguments yet
# from multipledispatch import dispatch
# multimethod = dispatch()
from multimethod import multimethod
from numba import generated_jit
import xarray

from dolo.compiler.model import Model
from dolo.numeric.grids import UniformCartesianGrid
from dolo.numeric.decision_rule import DecisionRule
from dolo.numeric.processes import MarkovChain, IIDProcess, DiscretizedIIDProcess
from dolo.numeric.grids import CartesianGrid, UnstructuredGrid, EmptyGrid

Expand Down Expand Up @@ -74,13 +81,13 @@ def fun(A: 'N* *...', x: 'N*d', w: 'float'):

# TODO: add default options for endo_grid, exo_grid, dp
@multimethod
def ergodic_distribution(model, dr):
def ergodic_distribution(model: Model, dr: DecisionRule):
return ergodic_distribution(model, dr, dr.exo_grid, dr.endo_grid, dr.dprocess)

@multimethod
def ergodic_distribution(model, dr,
def ergodic_distribution(model: Model, dr: DecisionRule,
exo_grid: UnstructuredGrid,
endo_grid: CartesianGrid,
endo_grid: UniformCartesianGrid,
dp: MarkovChain,
compute_μ=True):

Expand Down Expand Up @@ -134,7 +141,7 @@ def ergodic_distribution(model, dr,


@multimethod
def ergodic_distribution(model, dr,
def ergodic_distribution(model: Model, dr: DecisionRule,
exo_grid: EmptyGrid,
endo_grid: CartesianGrid,
dp: DiscretizedIIDProcess,
Expand Down
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ dependencies:
- matplotlib
- xarray
- multipledispatch
- multimethod
# - pip:
# - sphinx-better-theme==0.13
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
dolang
multipledispatch
multimethod
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
],
install_requires=[
"dolang", "pyyaml", "numba", "numpy", "sympy", "scipy", "quantecon", "pandas",
"interpolation", "ruamel.yaml", "xarray", "altair", "multipledispatch"
"interpolation", "ruamel.yaml", "xarray", "altair", "multipledispatch", "multimethod"
],
extras_require={
'interactive': ['ipython'],
Expand Down

0 comments on commit 2296a08

Please sign in to comment.