-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
836 additions
and
606 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import pytest | ||
|
||
|
||
def pytest_addoption(parser): | ||
parser.addoption("--skip-slow", action="store_true", | ||
help="skip slow tests") | ||
parser.addoption("--only-slow", action="store_true", | ||
help="run only slow tests") | ||
|
||
|
||
def pytest_runtest_setup(item): | ||
if 'slow' in item.keywords and item.config.getoption("--skip-slow"): # pragma: no cover | ||
pytest.skip("skipping due to --skip-slow") # pragma: no cover | ||
|
||
if 'slow' not in item.keywords and item.config.getoption("--only-slow"): # pragma: no cover | ||
pytest.skip("skipping due to --only-slow") # pragma: no cover |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import os | ||
import pandas as pd | ||
|
||
CURR_DIR = os.path.split(os.path.abspath(__file__))[0] | ||
|
||
|
||
def load(): | ||
""" | ||
Load the graduate school admissions dataused in the examples | ||
Returns | ||
------- | ||
data : DataFrame | ||
Dataset containing GRE, GPA and class rank, and admission decision | ||
""" | ||
return pd.read_csv(os.path.join(CURR_DIR, 'binary.csv.gz')) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import os | ||
import pandas as pd | ||
|
||
CURR_DIR = os.path.split(os.path.abspath(__file__))[0] | ||
|
||
|
||
def load(): | ||
""" | ||
Load the Core CPI data used in the examples | ||
Returns | ||
------- | ||
data : DataFrame | ||
Data set containing the CPI less Food and Energy | ||
Notes | ||
----- | ||
From the FRED database | ||
""" | ||
data = pd.read_csv(os.path.join(CURR_DIR, 'core-cpi.csv.gz')) | ||
data.Date = pd.to_datetime(data.Date) | ||
|
||
return data.set_index('Date') |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import os | ||
import pandas as pd | ||
|
||
CURR_DIR = os.path.split(os.path.abspath(__file__))[0] | ||
|
||
|
||
def load(): | ||
""" | ||
Load the AAA and BAA rates used in the examples | ||
Returns | ||
------- | ||
data : DataFrame | ||
Data set containing the rates on AAA and BAA rated bonds. | ||
""" | ||
data = pd.read_csv(os.path.join(CURR_DIR, 'default.csv.gz')) | ||
data.Date = pd.to_datetime(data.Date) | ||
|
||
return data.set_index('Date') |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import os | ||
import pandas as pd | ||
|
||
CURR_DIR = os.path.split(os.path.abspath(__file__))[0] | ||
|
||
|
||
def load(): | ||
""" | ||
Load the Fama-French factor data used in the examples | ||
Returns | ||
------- | ||
data : DataFrame | ||
Data set containing excess market, size and value factors and the | ||
risk-free rate | ||
Notes | ||
----- | ||
Provided by Ken French, | ||
http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/data_library.html | ||
""" | ||
data = pd.read_csv(os.path.join(CURR_DIR, 'frenchdata.csv.gz')) | ||
data.Date = pd.to_datetime(data.Date) | ||
|
||
return data.set_index('Date') |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import os | ||
import pandas as pd | ||
|
||
CURR_DIR = os.path.split(os.path.abspath(__file__))[0] | ||
|
||
|
||
def load(): | ||
""" | ||
Load the NASDAQ Composite data used in the examples | ||
Returns | ||
------- | ||
data : DataFrame | ||
Data set containing OHLC, adjusted close and the trading volume. | ||
""" | ||
data = pd.read_csv(os.path.join(CURR_DIR, 'nasdaq.csv.gz')) | ||
data.Date = pd.to_datetime(data.Date) | ||
|
||
return data.set_index('Date') |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import os | ||
import pandas as pd | ||
|
||
CURR_DIR = os.path.split(os.path.abspath(__file__))[0] | ||
|
||
|
||
def load(): | ||
""" | ||
Load the S&P 500 data used in the examples | ||
Returns | ||
------- | ||
data : DataFrame | ||
Data set containing OHLC, adjusted close and the trading volume. | ||
""" | ||
data = pd.read_csv(os.path.join(CURR_DIR, 'sp500.csv.gz')) | ||
data.Date = pd.to_datetime(data.Date) | ||
|
||
return data.set_index('Date') |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import os | ||
import pandas as pd | ||
|
||
CURR_DIR = os.path.split(os.path.abspath(__file__))[0] | ||
|
||
|
||
def load(): | ||
""" | ||
Load the VIX Index data used in the examples | ||
Returns | ||
------- | ||
data : DataFrame | ||
Data set containing historical VIX | ||
""" | ||
data = pd.read_csv(os.path.join(CURR_DIR, 'vix.csv.gz')) | ||
data.Date = pd.to_datetime(data.Date) | ||
data.vix = pd.to_numeric(data.vix, errors='coerce') | ||
return data.set_index('Date') |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import os | ||
import pandas as pd | ||
|
||
CURR_DIR = os.path.split(os.path.abspath(__file__))[0] | ||
|
||
|
||
def load(): | ||
""" | ||
Load the West Texas Intermediate crude oil price data used in the examples | ||
Returns | ||
------- | ||
data : DataFrame | ||
Data set containing the price of WTI | ||
Notes | ||
----- | ||
From the FRED database | ||
""" | ||
data = pd.read_csv(os.path.join(CURR_DIR, 'wti.csv.gz')) | ||
data.Date = pd.to_datetime(data.Date) | ||
data.DCOILWTICO = pd.to_numeric(data.DCOILWTICO, errors='coerce') | ||
|
||
return data.set_index('Date') |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import glob | ||
import os | ||
import sys | ||
|
||
import pytest | ||
|
||
try: | ||
import jupyter_client | ||
import nbformat | ||
from nbconvert.preprocessors import ExecutePreprocessor | ||
# matplotlib is required for most notebooks | ||
import matplotlib # noqa: F401 | ||
|
||
kernels = jupyter_client.kernelspec.find_kernel_specs() | ||
except ImportError: # pragma: no cover | ||
pytestmark = pytest.mark.skip(reason='Required packages not available') | ||
|
||
SLOW_NOTEBOOKS = ['multiple-comparison_examples.ipynb'] | ||
|
||
kernel_name = 'python%s' % sys.version_info.major | ||
|
||
head, _ = os.path.split(__file__) | ||
NOTEBOOK_DIR = os.path.abspath(os.path.join(head, '..', '..', 'examples')) | ||
|
||
nbs = sorted(glob.glob(os.path.join(NOTEBOOK_DIR, '*.ipynb'))) | ||
ids = list(map(lambda s: os.path.split(s)[-1].split('.')[0], nbs)) | ||
if not nbs: # pragma: no cover | ||
pytest.mark.skip(reason='No notebooks found and so no tests run') | ||
|
||
|
||
@pytest.fixture(params=nbs, ids=ids) | ||
def notebook(request): | ||
return request.param | ||
|
||
|
||
@pytest.mark.slow | ||
def test_notebook(notebook): | ||
nb_name = os.path.split(notebook)[-1] | ||
if nb_name in SLOW_NOTEBOOKS: | ||
pytest.skip('Notebook is too slow to test') | ||
nb = nbformat.read(notebook, as_version=4) | ||
ep = ExecutePreprocessor(allow_errors=False, | ||
timeout=240, | ||
kernel_name=kernel_name) | ||
ep.preprocess(nb, {'metadata': {'path': NOTEBOOK_DIR}}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.