Code Monkey home page Code Monkey logo

un-og-training's Introduction

UN-OG-Training

Org United Nations DESA OSE Lab cataloged OS License: AGPL-3.0 Jupyter Book Badge
Package Python 3.10 Python 3.11
Testing example event parameter example event parameter example event parameter Codecov

Training materials for United Nations country-specific overlapping generations model. The online rendered Jupyter Book for these training materials is at https://www.openrg.com/UN-OG-Training.

un-og-training's People

Contributors

rickecon avatar jdebacker avatar

Forkers

rickecon

un-og-training's Issues

Calibration of tax functions

How much detail should we add about calibrating tax functions? We must assume most countries won't have microsimulation models to link to. Given that, do we present just linear? Show how to estimate Gouveia-Strauss with aggregate data?

Calibrating pensions

We should explain the calibration of pensions. OG-Core now allows for defined benefits, notional defined contributions, points system, and a US-style SS system.

Reading pickled `Specifications` object in Python 3.11

In PR #24, I inserted the following code block into the OG/Ouput.md chapter:

import ogcore.output_tables as ot
from io import BytesIO
import pickle
import requests
path_dict = {
    "TPI": [
        "https://github.com/PSLmodels/OG-Core/blob/master/tests/test_io_data/TPI_vars_baseline.pkl?raw=true",
        "https://github.com/PSLmodels/OG-Core/blob/master/tests/test_io_data/TPI_vars_reform.pkl?raw=true"
            ],
    "Params": [
        "https://github.com/PSLmodels/OG-Core/blob/master/tests/test_io_data/model_params_baseline.pkl?raw=true",
        "https://github.com/PSLmodels/OG-Core/blob/master/tests/test_io_data/model_params_reform.pkl?raw=true"

    ]
}
output_dict = {
    "TPI": [],
    "Params": []
}
for key in path_dict.keys():
    for path in path_dict[key]:
        r = requests.get(path)
        output_dict[key].append(pickle.load(BytesIO(r.content)))
# make table
table = ot.macro_table(output_dict["TPI"][0], output_dict["Params"][0], output_dict["TPI"][1], output_dict["Params"][1], output_type="pct_diff", num_years=10, start_year= output_dict["Params"][0].start_year)

I have no issue executing this in Python 3.10. But with Python 3.11, there is an error with the pickle.load command when trying to read the pickle file containing the model parameters (which is a ogcore.parameters.Specifications object pickled with Cloudpickle). The traceback is:

TypeError                                 Traceback (most recent call last)
Cell In[2], line 24
     22     for path in path_dict[key]:
     23         r = requests.get(path)
---> 24         output_dict[key].append(pickle.load(BytesIO(r.content)))
     25 # make table
     26 table = ot.macro_table(output_dict["TPI"][0], output_dict["Params"][0], output_dict["TPI"][1], output_dict["Params"][1], output_type="pct_diff", num_years=10, start_year= output_dict["Params"][0].start_year)

TypeError: code() argument 13 must be str, not int

I've tried just using cloudpickle and pickle.loads to unpack and still get an error.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.