Skip to content

Commit

Permalink
Release 2.0.0. (#377)
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasraabe committed Aug 19, 2020
1 parent dc44f6a commit 6955430
Show file tree
Hide file tree
Showing 20 changed files with 81 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .conda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ requirements:
- pyyaml
- scipy
test:
reqires:
requires:
- pytest
- pytest-xdist
commands:
Expand Down
14 changes: 9 additions & 5 deletions .github/workflows/continuous-integration-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ jobs:
shell: bash -l {0}
run: conda install -c conda-forge -c opensourceeconomics conda-build estimagic matplotlib python-snappy

- name: Validate codecov.yml
if: runner.os == 'Linux' && matrix.python-version == '3.8'
shell: bash -l {0}
run: cat codecov.yml | curl --data-binary @- https://codecov.io/validate

###############
# Test Matrix #
###############
Expand Down Expand Up @@ -84,6 +79,15 @@ jobs:
shell: bash -l {0}
run: bash <(curl -s https://codecov.io/bash) -F end_to_end -c

##################################
# Validate codecov configuration #
##################################

- name: Validate codecov.yml
if: runner.os == 'Linux' && matrix.python-version == '3.8'
shell: bash -l {0}
run: cat codecov.yml | curl --data-binary @- https://codecov.io/validate


pre-commit:

Expand Down
33 changes: 24 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.1.0
rev: v3.2.0
hooks:
- id: check-added-large-files
args: ['--maxkb=10']
- id: check-merge-conflict
- id: check-yaml
exclude: meta.yaml
Expand All @@ -13,32 +15,45 @@ repos:
- id: pyupgrade
args: [--py36-plus]
- repo: https://github.com/asottile/reorder_python_imports
rev: v2.3.2
rev: v2.3.5
hooks:
- id: reorder-python-imports
- repo: https://github.com/psf/black
rev: 19.10b0
hooks:
- id: black
- repo: https://github.com/asottile/blacken-docs
rev: v1.7.0
rev: v1.8.0
hooks:
- id: blacken-docs
additional_dependencies: [black]
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.3
hooks:
- id: flake8
types: [python]
additional_dependencies: [
flake8-alfred, flake8-bugbear, flake8-builtins, flake8-comprehensions,
flake8-docstrings, flake8-eradicate, flake8-print, flake8-todo,
flake8-unused-arguments, pep8-naming, pydocstyle, Pygments,
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.8.1rc3
rev: 0.9.0a0
hooks:
- id: doc8
- id: doc8
# - repo: https://github.com/codespell-project/codespell
# rev: v1.17.1
# hooks:
# - id: codespell
# - repo: https://github.com/mgedmin/check-manifest
# rev: '0.41'
# hooks:
Expand Down
3 changes: 3 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
codecov:
branch: main

coverage:
precision: 2
round: down
Expand Down
9 changes: 9 additions & 0 deletions development/testing/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import os

import pytest


@pytest.fixture(autouse=True)
def _fresh_directory(tmp_path):
"""Each test is executed in a fresh directory."""
os.chdir(tmp_path)
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
author = "The respy Development Team"

# The full version, including alpha/beta/rc tags.
release = "2.0.0dev5"
release = "2.0.0"
version = ".".join(release.split(".")[:2])

# -- General configuration ------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion docs/explanations/recommended_reading.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Train, K. (2009). `Discrete Choice Methods with Simulation
<https://eml.berkeley.edu/books/choice2.html>`_. *Cambridge: Cambridge University
Press.*

Stachurski, J. (2009). `Economic Dynamics: Theory and Compuation
Stachurski, J. (2009). `Economic Dynamics: Theory and Computation
<https://johnstachurski.net/edtc.html>`_. *MIT Press Books, The MIT Press, edition 1,
volume 1, number 0262012774, March.*

Expand Down
2 changes: 1 addition & 1 deletion docs/how_to_guides/impatient_robinson.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Up to now, we have implicitely assumed Robinson to be forward-looking with respect to his intertemporal preferences, such that he maximizes the expected present value of utility over the remaining lifetime according to\n",
"Up to now, we have implicitly assumed Robinson to be forward-looking with respect to his intertemporal preferences, such that he maximizes the expected present value of utility over the remaining lifetime according to\n",
"\n",
"$$\n",
" U_t(u_t, u_{t+1}, ...) \\equiv \\sum^{T}_{t=0}\n",
Expand Down
8 changes: 4 additions & 4 deletions docs/how_to_guides/numerical_integration.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"source": [
"# Improving Numerical Integration Methods\n",
"\n",
"The solution and estimation of Dynamic Discrete Choice Models (DDCM) is often constrained by computational feasability. For instance, Keane and Wolpin (1997) and subsequent work that estimates DDCM's of post-graduation career dynamics abstract from many important determinants of earnings and mobility dynamics. Examples include the isolation from match heterogeneity, permanent skill shocks, and abscence of multidimensional skill structures.\n",
"The solution and estimation of Dynamic Discrete Choice Models (DDCM) is often constrained by computational feasibility. For instance, Keane and Wolpin (1997) and subsequent work that estimates DDCM's of post-graduation career dynamics abstract from many important determinants of earnings and mobility dynamics. Examples include the isolation from match heterogeneity, permanent skill shocks, and absence of multidimensional skill structures.\n",
"\n",
"Keane and Wolpin (1994, 1997) split their occupational classes into white- and blue-collar occupations. Nevertheless, empirical evidence suggests that skill requirements vary substantially within blue- and white-collar occupations. Arguably any aggregation of occupational classes should be able to account for meaningful skill differences. Acemoglu and Autor (2011) suggest four aggregate groups that are explicitly derived from the task content of classified three digit occupations in the US data.[<sup>1</sup>](#fn1)\n",
"\n",
Expand Down Expand Up @@ -453,7 +453,7 @@
"\n",
"If we are able to calculate all expressions in the Koksma-Hlawka inequality the required number of iterations for a pre-specified precisions follows immediately. The world could be so easy if the derivation of the Koksma-Hlawka inequality would not point towards a drawback: it does not apply to functions that have (simple) discontinuities. To circumvent this issue Brandolini et al. (2013) derive a Koksma-Hlawka-type inequality which applies to piecewise smooth functions. Nevertheless, oftentimes it is not feasible to calculate the expressions involved in the Koksma-Hlawka inequality (at least not without difficulties). \n",
"\n",
"However, the Koksma-Hlawka inequality offers an additional insight: point sets with a small discrepancy guarantee small errors when using quasi-Monte Carlo methods for numerial integration. Number generators based on integer arithmetic module two, like the Sobol-sequence, provide additional equidistribution properties *whenever* the number of iterations $N$ is a power of two, $N = 2^n- 1$. Specifically, our [notebook](https://github.com/HumanCapitalAnalysis/student-project-rafael_suchy/blob/master/notebooks/98_low_discrepancy_sequences_application_integration.ipynb) demonstrates that those sequences are only equidistant, and hence have the minimal star discrepancy, if we have $N = 2^n – 1$ points.[<sup>7</sup>](#fn7) Consequently, employing iterations that satisfy this condition we can improve our procedure without incurring additional costs. This fact came to our mind when elaborating on the concept of Frolov points (Kacwin et al. (2018))."
"However, the Koksma-Hlawka inequality offers an additional insight: point sets with a small discrepancy guarantee small errors when using quasi-Monte Carlo methods for numerical integration. Number generators based on integer arithmetic module two, like the Sobol-sequence, provide additional equidistribution properties *whenever* the number of iterations $N$ is a power of two, $N = 2^n- 1$. Specifically, our [notebook](https://github.com/HumanCapitalAnalysis/student-project-rafael_suchy/blob/master/notebooks/98_low_discrepancy_sequences_application_integration.ipynb) demonstrates that those sequences are only equidistant, and hence have the minimal star discrepancy, if we have $N = 2^n – 1$ points.[<sup>7</sup>](#fn7) Consequently, employing iterations that satisfy this condition we can improve our procedure without incurring additional costs. This fact came to our mind when elaborating on the concept of Frolov points (Kacwin et al. (2018))."
]
},
{
Expand Down Expand Up @@ -697,14 +697,14 @@
"<span id=\"fn1\"><sup>1</sup>\n",
" Over the last few decades the empirical literature established a relatively weak economic performance of occupations that require workers to solve routine cognitive or routine manual tasks. Dimensions of occupational skill requirements, skill prices, and employment shares evolved substantially in the last years. As the authors suggest, distinction between \n",
" $~~~~~$ a) abstract, non-routine tasks (e.g. managerial) \n",
" $~~~~~$ b) routine cognitive tasks (e.g. adminstrative and sales), \n",
" $~~~~~$ b) routine cognitive tasks (e.g. administrative and sales), \n",
" $~~~~~$ c) routine manual tasks (e.g. production), \n",
" $~~~~~$ d) non-routine manual tasks (e.g. service occupations). \n",
"may be more appropriate \n",
"</span>\n",
"\n",
"<span id=\"fn2\"><sup>2</sup>\n",
" Please do not get confused. Although the option name is called `monte_carlo_sequence` it does indeed inlcude the Quasi-Monte Carlo methods. The naming convenation was chosen this way, because in ``respy`` we regard Monte Carlo methods as the aggregate group. \n",
" Please do not get confused. Although the option name is called `monte_carlo_sequence` it does indeed include the Quasi-Monte Carlo methods. The naming convenation was chosen this way, because in ``respy`` we regard Monte Carlo methods as the aggregate group. \n",
"</span>\n",
"\n",
"<span id=\"fn3\"><sup>3</sup>\n",
Expand Down
2 changes: 1 addition & 1 deletion docs/reference_guides/scalability.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"source": [
"# Scalability\n",
"\n",
"The solution and estimation of finite-horizon discrete choice dynamic programming model appears straightforward. However, it entails a considerable computational burden due to the well known curse of dimensionality (Bellman and Dreyfus, 1962). The figure below illustrates how the total number of states increases exponentially with each period. The size of the state space is shown for Keane and Wolpin (1994) (all models have the same state space) and the base and extended model of Keane and Wolpin (1997). The latter two models are different because the state space of the base parameterization does not include information on the previous activity which significantly reduces the complexity of the model. Note that the y-axis us log-scaled to compensate for the loss in readibility due to exponential growth."
"The solution and estimation of finite-horizon discrete choice dynamic programming model appears straightforward. However, it entails a considerable computational burden due to the well known curse of dimensionality (Bellman and Dreyfus, 1962). The figure below illustrates how the total number of states increases exponentially with each period. The size of the state space is shown for Keane and Wolpin (1994) (all models have the same state space) and the base and extended model of Keane and Wolpin (1997). The latter two models are different because the state space of the base parameterization does not include information on the previous activity which significantly reduces the complexity of the model. Note that the y-axis us log-scaled to compensate for the loss in readability due to exponential growth."
]
},
{
Expand Down
17 changes: 14 additions & 3 deletions docs/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,19 @@ releases are available on `Anaconda.org
random, moved to Github Actions, and more badges.
- :gh:`323` adds an informative message if simulated individuals cannot be mapped to
states in the state space (:ghuser:`mo2561057`, :ghuser:`tobiasraabe`).
- :gh:`325` adds an how-to guide on numerical integration techniques
(:ghuser:`rafaelsuchy`).
- :gh:`331` better parsing for observables (and exogenous processes) and better model
tests and docstrings (:ghuser:`tobiasraabe`).
- :gh:`342` partitions the state space to parts which are specific to the period, choice
set and dense values (:ghuser:`mo2561057`, :ghuser:`tobiasraabe`).
- :gh:`344` redesigns the documentation. The foundation are four categories of
documents, tutorials, explanations, how-to guides, and reference guides
(:ghuser:`tobiasraabe`).
- :gh:`347` allows to specify models with hyperbolic discounting
(:ghuser:`SofiaBadini`).
- :gh:`356` adds how-to guide for estimation of parameters with msm (:ghuser:`amageh`).
- :gh:`357` adds a tutorial explaining the basic interface (:ghuser:`SofiaBadini`).
- :gh:`359` fixes a Numba deprecation warning and some errors in the constraints of
pre-defined models.
- :gh:`361` adds standard deviations of parameters for example models
Expand All @@ -90,12 +100,13 @@ releases are available on `Anaconda.org
use with `estimagic <https://github.com/OpenSourceEconomics/estimagic>`_
(:ghuser:`amageh`).
- :gh:`369` adds second set of parameters for kw_97 models (:ghuser:`amageh`).
- :gh:`373` refactors the law of motion and simplifies the collection of child indices
(:ghuser:`tobiasraabe`).
- :gh:`371` changes the names of the criterion functions for maximum likelihood and msm
estimation. Makes replacement functions optional for estimation with
msm and sets identity matrix as default weighting matrix (:ghuser:`amageh`).
- :gh:`374` renames caching options to ``"cache_path"`` and ``"cache_compression"``.
- :gh:`373` refactors the law of motion and simplifies the collection of child indices
(:ghuser:`tobiasraabe`).
- :gh:`374` renames caching options to ``"cache_path"`` and ``"cache_compression"``
(:ghuser:`tobiasraabe`).

*Releases prior to the second version were published on PyPI, but later deleted. You can
still checkout the following releases using the corresponding tags in the repository.*
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/tutorial_observables.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Then, we add three additional rows to `params`, to specificy:\n",
"Then, we add three additional rows to `params`, to specify:\n",
"\n",
"- The probability with which Robinson will find himself in rich and in poor fishing grounds;\n",
"- The value of $\\zeta^f$, which here is set to be positive and constant. \n",
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/tutorial_params_options_simulate.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"A payoff of structural models is the possibility to simulate the same model in a counterfactual environment, to help answer \"what if\" questions that can be highly relevant for policy purposes. As an example, in models of educational choice, the analysis of comparitive statics is often applied to evaluate the effect of alternative tuition policies on average educational attainment. \n",
"A payoff of structural models is the possibility to simulate the same model in a counterfactual environment, to help answer \"what if\" questions that can be highly relevant for policy purposes. As an example, in models of educational choice, the analysis of comparative statics is often applied to evaluate the effect of alternative tuition policies on average educational attainment. \n",
"\n",
"We will now show how, in this simple Robinson Crusoe economy, changing one parameter affects Robinson's behavior: How do Robinson's choices change if we increase the return to experience in fishing? We can simulate the model again under a different set of parameters and inspect Robinson's new choices. "
]
Expand Down
2 changes: 1 addition & 1 deletion respy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"add_noise_to_params",
]

__version__ = "2.0.0dev5"
__version__ = "2.0.0"


def test(*args, **kwargs):
Expand Down
4 changes: 2 additions & 2 deletions respy/conditional_draws.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def calculate_conditional_draws(
"""Calculate the conditional draws from base draws, updated means and updated chols.
We need to pass ``max_log_float`` to the function, because the global variables
``MAX_LOG_FLOAT`` cannot be used directly withing the guvectorize.
``MAX_LOG_FLOAT`` cannot be used directly within the guvectorize.
Parameters
----------
Expand Down Expand Up @@ -330,7 +330,7 @@ def make_cholesky_unique(chol):
Cholesky factors are only unique with the additional requirement that all diagonal
elements are positive. This is done automatically by np.linalg.cholesky.
Since we calucate cholesky factors by QR decompositions we have to do it manually.
Since we calculate cholesky factors by QR decompositions we have to do it manually.
It is obvious from that this is admissible because:
Expand Down
6 changes: 3 additions & 3 deletions respy/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
import respy as rp


@pytest.fixture(scope="function", autouse=True)
def fresh_directory(tmp_path):
@pytest.fixture(autouse=True)
def _fresh_directory(tmp_path):
"""Each test is executed in a fresh directory."""
os.chdir(tmp_path)


@pytest.fixture(autouse=True)
def patch_doctest_namespace(doctest_namespace):
def _patch_doctest_namespace(doctest_namespace):
"""Patch the namespace for doctests.
This function adds some packages to namespace of every doctest.
Expand Down
4 changes: 2 additions & 2 deletions respy/pre_processing/model_checking.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ def validate_options(o):
or o["interpolation_points"] == -1
)
assert _is_positive_nonzero_integer(o["simulation_agents"])
assert isinstance(o["core_state_space_filters"], list) and all(
assert isinstance(o["core_state_space_filters"], list) and all( # noqa: PT018
isinstance(filter_, str) for filter_ in o["core_state_space_filters"]
)
assert isinstance(o["negative_choice_set"], dict) and all(
assert isinstance(o["negative_choice_set"], dict) and all( # noqa: PT018
isinstance(key, str)
and isinstance(val, list)
and all(isinstance(condition, str) for condition in val)
Expand Down
2 changes: 1 addition & 1 deletion respy/tests/test_conditional_draws.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from respy.config import TEST_RESOURCES_DIR


@pytest.fixture
@pytest.fixture()
def kalman_results():
"""The inputs and outputs were generated using a well tested Kalman filter."""
with open(TEST_RESOURCES_DIR / "conditional_draws_fixture.pickle", "rb") as p:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

setup(
name="respy",
version="2.0.0dev5",
version="2.0.0",
description=DESCRIPTION,
long_description=DESCRIPTION + "\n\n" + README,
long_description_content_type="text/x-rst",
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ max-line-length = 88
ignore =
E203 ; ignores whitespace around : which is enforced by Black.
W503 ; ignores linebreak before binary operator which is enforced by Black.
PT006 ; ignores using tuples of strings as default for pytest parametrize.
warn-symbols =
pytest.mark.wip = Remove 'wip' mark for tests before commits.
pytest.mark.skip = Remove 'skip' flag for tests before commits.
Expand Down

0 comments on commit 6955430

Please sign in to comment.