Adding notebook and codes for Krusell and Smith (1998)#39
Adding notebook and codes for Krusell and Smith (1998)#39albep wants to merge 1 commit intoQuantEcon:masterfrom
Conversation
|
Given this is a Julia project -- and the current notebook dependency tools support python only -- for now we should just add them in the |
|
I think this is a great time to write up some code for a proper solution in Julia. @mmcky can you summarize all the things the python dependency system currently does? |
|
It is pretty basic -- it just uses requests to fetch a file and place it in the import os
import requests
#-Remote Structure-#
REPO = "https://github.com/QuantEcon/QuantEcon.notebooks"
RAW = "raw"
BRANCH = "master"
DEPS = "dependencies" #Hard Coded Dependencies Folder on QuantEcon.notebooks
def fetch_nb_dependencies(files, repo=REPO, raw=RAW, branch=BRANCH, deps=DEPS, overwrite=False, verbose=True):
"""
Retrieve raw files from QuantEcon.notebooks or any other Github repo
Parameters
----------
file_list list or dict
A list of files to specify a collection of filenames
A dict of dir : list(files) to specify a directory
repo str, optional(default=REPO)
branch str, optional(default=BRANCH)
deps str, optional(default=DEPS)
overwrite bool, optional(default=False)
verbose bool, optional(default=True)
TODO
----
1. Should we update this to allow people to specify their own folders on a different GitHub repo?
"""
#-Generate Common Data Structure-#
if type(files) == list:
files = {"" : files}
#-Obtain each requested file-#
for directory in files.keys():
if directory != "":
if verbose: print("Parsing directory: %s")
for fl in files[directory]:
if directory != "":
fl = directory+"/"+fl
#-Check for Local Copy of File (Default Behaviour is to Skip)-#
if not overwrite:
if os.path.isfile(fl):
if verbose: print("A file named %s already exists in the specified directory ... skipping download."%fl)
continue
else:
if verbose: print("Overwriting file %s ..."%fl)
if verbose: print("Fetching file: %s"%fl)
#-Get file in OS agnostic way using requests-#
url = "/".join([repo,raw,branch,deps,fl])
r = requests.get(url)
with open(fl, "wb") as fl:
fl.write(r.content) |
This PR adds the directory
krusell_smith_98_depsindependencies. Such directory contains 2 Julia files with the programs to solve the model and replicate some results from Krusell and Smith (1998). These programs are run in the notebookkrusell_smith_98.ipynb- also added through this commit - with extensive descriptions.