Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/gboehl/pydsge
Browse files Browse the repository at this point in the history
  • Loading branch information
gboehl committed Feb 11, 2022
2 parents 39c7dbb + 13b48e7 commit 5dbfc79
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 45 deletions.
56 changes: 28 additions & 28 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,34 +29,34 @@ repos:
#hooks:
#- id: blacken-docs
#additional_dependencies: [black]
- repo: https://github.com/PyCQA/flake8
rev: 3.9.2
hooks:
- id: flake8
args: # arguments to configure flake8
# making flake8 compatible with Black
- "--max-line-length=88"
# ignore errors for Black compatability
# E203: ignore whitespace around " : "
# T000: ignore TODOs
# W503: ignore linebreak before binary operator
# PT5006: ignore tuples as default for pytest parametrize
- "--ignore=E203,T000,W503,PT006,"
additional_dependencies: [
flake8-alfred,
flake8-bugbear,
flake8-builtins,
flake8-comprehensions,
flake8-docstrings,
flake8-eradicate,
flake8-print,
flake8-pytest-style,
flake8-todo,
flake8-unused-arguments,
pep8-naming,
pydocstyle,
Pygments,
]
#- repo: https://github.com/PyCQA/flake8
#rev: 3.9.2
#hooks:
#- id: flake8
#args: # arguments to configure flake8
## making flake8 compatible with Black
#- "--max-line-length=88"
## ignore errors for Black compatability
## E203: ignore whitespace around " : "
## T000: ignore TODOs
## W503: ignore linebreak before binary operator
## PT5006: ignore tuples as default for pytest parametrize
#- "--ignore=E203,T000,W503,PT006,"
#additional_dependencies: [
#flake8-alfred,
#flake8-bugbear,
#flake8-builtins,
#flake8-comprehensions,
#flake8-docstrings,
#flake8-eradicate,
#flake8-print,
#flake8-pytest-style,
#flake8-todo,
#flake8-unused-arguments,
#pep8-naming,
#pydocstyle,
#Pygments,
#]
# - repo: https://github.com/PyCQA/doc8
# rev: 0.9.0
# hooks:
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pydsge

Contains the functions and classes for solving, filtering and estimating DSGE models at the ZLB (or with other occasionally binding constraints).

A collection of models that can (and were) used with this package can be found in `another repo <https://github.com/gboehl/projectlib/tree/master/yamls>`_.
A collection of models that can be (and were) used with this package can be found in `another repo <https://github.com/gboehl/projectlib/tree/master/yamls>`_.

Installation
-------------
Expand Down
7 changes: 0 additions & 7 deletions docs/modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,6 @@ Module Documentation
:undoc-members:
:show-inheritance:

``pydsge.partfilt``
-------------------
.. automodule:: pydsge.partfilt
:members:
:undoc-members:
:show-inheritance:

``pydsge.symbols``
------------------
.. automodule:: pydsge.symbols
Expand Down
3 changes: 3 additions & 0 deletions pydsge/clsmethods.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,9 @@ def load_data(self, df, start=None, end=None):

d = d.loc[start:end]

if np.any(d.isna()):
raise Exception("Data must not contain `NaN`s.")

self.data = d
self.fdict["data"] = cpickle.dumps(d, protocol=4)
self.fdict["obs"] = self.observables
Expand Down
12 changes: 3 additions & 9 deletions pydsge/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ def mdd_lp(chain, lprobs, calc_hess=False):
return mdd


def mdd_mhm(chain, lprobs, alpha=0.05, verbose=False, debug=False):
def mdd_mhm(chain, lprobs, pool=None, alpha=0.05, verbose=False, debug=False):
"""Approximate the marginal data density useing modified harmonic mean."""

from grgrlib.stats import logpdf
Expand Down Expand Up @@ -572,14 +572,8 @@ def runner(chunk):
res[i] = -np.inf
return res

if not debug:
if hasattr(self, "pool"):
from .estimation import create_pool

create_pool(self)

nbatches = self.pool.ncpus

if not debug and pool is not None:
nbatches = pool.ncpus
batches = pool.imap(runner, np.array_split(chain, nbatches))
mls = np.vstack(list(batches))
else:
Expand Down

0 comments on commit 5dbfc79

Please sign in to comment.