QuantEcon.py

repository·main·Indexed 25 days ago

https://github.com/quantecon/quantecon.py

A high-performance, open-source Python library for quantitative economics. It provides tools for solving complex economic models, including modules for game theory, Markov chains, optimization, and random number generation. Key features include Discrete Dynamic Programming (DDP) solvers, ARMA models, Kronecker products, and specialized grid generation tools like cartesian and simplex grids.

Tokens
8K
Snippets
15
Records
99
Agent score
80%

What's inside quantecon

  1. Overview of the quantecon library modules

    main

    The quantecon Python library provides a suite of modules for quantitative economics and computational science. Key modules available for end-users include:

    • game_theory: Tools for game theoretic modeling.
    • markov: Implementations and utilities for Markov chains.
    • optimize: Optimization algorithms.
    • random: Utilities for random number generation.
    • tools: A collection of general-purpose tools.
    • util: Internal utilities (primarily used by package developers).
  2. Automate documentation builds with `make myhtml`

    main

    The documentation Makefile includes a utility command myhtml that automates a clean build process. Running make myhtml performs the following sequence:

    1. Runs srcclean to remove old generated modules, models, tools, and index files.
    2. Re-installs the quantecon library locally.
    3. Runs qe_apidoc.py to regenerate API documentation.
    4. Runs make html to build the final Sphinx HTML output.

    This is the recommended way to ensure a fresh, consistent build.

    make myhtml
  3. Install QuantEcon.py from source

    main

    To install the package manually from the GitHub repository, clone the repository and use flit to perform the installation.

    git clone https://github.com/QuantEcon/QuantEcon.py
    cd QuantEcon.py
    pip install flit
    flit install
  4. Write and build documentation for QuantEcon.py

    main

    QuantEcon.py uses the numpydoc format for docstrings to ensure consistency and compatibility with Sphinx's autodoc.

    To verify how your docstrings render in HTML locally, install the documentation requirements and build the HTML using make. The output will be located in docs/build/html.

    pip install -r docs/rtd-requirements.txt
    cd docs
    make html
  5. Build the QuantEcon documentation

    main

    To generate the documentation from source, follow these steps:

    1. Install the quantecon library locally in your environment:
      cd ..
      pip install .
      cd docs
    2. Execute the local API documentation generator script:
      python qe_apidoc.py
    3. Run Sphinx using the provided Makefile (Unix-based systems only):
      make html
    4. View the generated documentation by opening build/html/index.html in your browser.
    cd ..
    pip install .
    cd docs
    python qe_apidoc.py
    make html
  6. Install quantecon via pip or conda

    main

    You can install quantecon using pip or conda. It is recommended to use the Anaconda Python distribution for a full suite of scientific tools. If using conda, the conda-forge channel typically provides more recent releases than the main anaconda channel.

    pip install quantecon
    
    # Or using conda-forge
    conda install -c conda-forge quantecon
  7. Set up a QuantEcon.py development environment

    main

    To develop QuantEcon.py, it is recommended to use an isolated conda environment. The repository provides an environment.yml file (named qe) that includes the scientific stack and development tools like pytest, flake8, and flit.

    After creating the environment, install the package in editable mode using flit install --symlink so that changes to the source code are reflected immediately.

    git clone https://github.com/QuantEcon/QuantEcon.py
    cd QuantEcon.py
    conda env create -f environment.yml
    conda activate qe
    flit install --symlink