notebooks
Support functions to Support QuantEcon.notebooks
The purpose of these utilities is to implement simple support functions to allow for automatic downloading of any support files (python modules, or data) that may be required to run demonstration notebooks.
Note
Files on the REMOTE Github Server can be organised into folders but they will end up at the root level of when downloaded as a support File
“https://github.com/QuantEcon/QuantEcon.notebooks/raw/master/dependencies/mpi/something.py” –> ./something.py
Deprecated since version 0.13.0: fetch_nb_dependencies is deprecated and will be removed in v1.0, along
with this module. It has no remaining callers in the QuantEcon lecture
series, and requests is no longer a mandatory dependency of
QuantEcon.py. Datasets referenced by the lectures live in
QuantEcon/data-lectures and
should be fetched by stable URL with the tool of your choice.
- quantecon.util.notebooks.fetch_nb_dependencies(files, repo='https://github.com/QuantEcon/QuantEcon.notebooks', raw='raw', branch='master', folder='dependencies', overwrite=False, verbose=True)[source]
Retrieve raw files from QuantEcon.notebooks or other Github repo
Deprecated since version 0.13.0: Deprecated and will be removed in v1.0. Fetch data by stable URL from QuantEcon/data-lectures instead.
- Parameters:
- fileslist or dict
A list of files to specify a collection of filenames, or a dict of dir : list(files) to specify a directory
- repostr, optional(default=REPO)
The Github repository to fetch the files from
- rawstr, optional(default=RAW)
This is here in case github changes access to their raw files through web links
- branchstr, optional(default=BRANCH)
The branch of the repository to fetch the files from
- folderstr, optional(default=FOLDER)
The folder in the repository that contains the requested files
- overwritebool, optional(default=False)
If True, overwrite a local copy of the file if one is present
- verbosebool, optional(default=True)
If True, then print a status message for each requested file
- Returns:
- statuslist of bool
One entry per requested file: True if the file was downloaded, and False if a local copy was found and the download was skipped
Examples
Consider a notebook that is dependant on a
csvfile to execute. If this file is located in a Github repository then it can be fetched using this utilityAssuming the file is at the root level in the
masterbranch then:>>> from quantecon.util import fetch_nb_dependencies >>> status = fetch_nb_dependencies(["test.csv"], repo="https://<github_address>")
More than one file may be requested in the list provided
>>> status = fetch_nb_dependencies(["test.csv", "data.csv"], repo="https://<github_address>")
A folder location can be added using
folder=>>> status = fetch_nb_dependencies(["test.csv"], repo="https://<github_address>", folder="data")
You can also specify a specific branch using
branch=keyword argument.This will download the requested file(s) to your local working directory. The default behaviour is not to overwrite a local file if it is present. This can be switched off by setting
overwrite=True.