Skip to content

Commit

Permalink
Merge pull request #46 from ljwolf/tests
Browse files Browse the repository at this point in the history
[WIP] add model csvs rather than pickles
ljwolf authored Jan 5, 2019
2 parents 02337c6 + d3e626d commit f77e334
Showing 25 changed files with 706 additions and 2,175 deletions.
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -4,8 +4,8 @@ branches:
only:
- master
python:
- "3.5"
- "3.6"
- 3.5
- 3.6

env:
- PYSAL_PLUS=false
@@ -19,7 +19,7 @@ matrix:
env: PYSAL_PYPI=false

before_install:
- wget https://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh
- wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
- chmod +x miniconda.sh
- ./miniconda.sh -b -p ./miniconda
- export PATH=`pwd`/miniconda/bin:$PATH
@@ -49,6 +49,7 @@ notifications:
email:
recipients:
- tayoshan@gmail.com
- jgaboardi@gmail.com
on_change: change
on_failure: always

Binary file removed mgwr/tests/georgia/.DS_Store
Binary file not shown.
160 changes: 0 additions & 160 deletions mgwr/tests/georgia/GData_utm.csv

This file was deleted.

Binary file removed mgwr/tests/georgia/G_utm.dbf
Binary file not shown.
Binary file removed mgwr/tests/georgia/G_utm.sbn
Binary file not shown.
Binary file removed mgwr/tests/georgia/G_utm.sbx
Binary file not shown.
Binary file removed mgwr/tests/georgia/G_utm.shp
Binary file not shown.
Binary file removed mgwr/tests/georgia/G_utm.shx
Binary file not shown.
45 changes: 0 additions & 45 deletions mgwr/tests/georgia/georgia_BS_F.ctl

This file was deleted.

160 changes: 0 additions & 160 deletions mgwr/tests/georgia/georgia_BS_F_listwise.csv

This file was deleted.

170 changes: 0 additions & 170 deletions mgwr/tests/georgia/georgia_BS_F_summary.txt

This file was deleted.

45 changes: 0 additions & 45 deletions mgwr/tests/georgia/georgia_BS_NN.ctl

This file was deleted.

160 changes: 0 additions & 160 deletions mgwr/tests/georgia/georgia_BS_NN_listwise.csv

This file was deleted.

170 changes: 0 additions & 170 deletions mgwr/tests/georgia/georgia_BS_NN_summary.txt

This file was deleted.

45 changes: 0 additions & 45 deletions mgwr/tests/georgia/georgia_GS_F.ctl

This file was deleted.

160 changes: 0 additions & 160 deletions mgwr/tests/georgia/georgia_GS_F_listwise.csv

This file was deleted.

168 changes: 0 additions & 168 deletions mgwr/tests/georgia/georgia_GS_F_summary.txt

This file was deleted.

45 changes: 0 additions & 45 deletions mgwr/tests/georgia/georgia_GS_NN.ctl

This file was deleted.

160 changes: 0 additions & 160 deletions mgwr/tests/georgia/georgia_GS_NN_listwise.csv

This file was deleted.

165 changes: 0 additions & 165 deletions mgwr/tests/georgia/georgia_GS_NN_summary.txt

This file was deleted.

160 changes: 160 additions & 0 deletions mgwr/tests/georgia_mgwr_results.csv

Large diffs are not rendered by default.

971 changes: 513 additions & 458 deletions mgwr/tests/test_gwr.py

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions mgwr/tests/test_sel_bw.py
Original file line number Diff line number Diff line change
@@ -5,15 +5,15 @@
import os
import numpy as np
from libpysal import io
import libpysal as ps
import unittest
from spglm.family import Gaussian, Poisson, Binomial
from ..sel_bw import Sel_BW
from numpy.testing import assert_allclose

class TestSelBW(unittest.TestCase):
def setUp(self):
data_path = os.path.join(os.path.dirname(__file__),'georgia/GData_utm.csv')
#data = libpysal.open(data_path)
data_path = ps.examples.get_path("GData_utm.csv")
data = io.open(data_path)
self.coords = list(zip(data.by_col('X'), data.by_col('Y')))
self.y = np.array(data.by_col('PctBach')).reshape((-1,1))
83 changes: 25 additions & 58 deletions notebooks/GWR_MGWR_example.ipynb
Original file line number Diff line number Diff line change
@@ -2,28 +2,24 @@
"cells": [
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": true
},
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import scipy as sp\n",
"# import scipy as sp\n",
"from mgwr.sel_bw import Sel_BW\n",
"from mgwr.gwr import GWR, MGWR\n",
"# from mgwr.gwr import GWR, MGWR\n",
"import pandas as pd\n",
"import libpysal as ps\n",
"import pickle as pk\n",
"import os"
"# import pickle as pk\n",
"# import os"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": true
},
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"data = ps.io.open(ps.examples.get_path('GData_utm.csv'))\n",
@@ -41,17 +37,25 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"bw: 117.0\n",
"aicc: 299.0508086830288\n",
"ENP: 11.804769716730096\n",
"sigma2: 0.34774354749782793\n"
"bw: 117.0\n"
]
},
{
"ename": "NameError",
"evalue": "name 'GWR' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-3-2da488ac544f>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 9\u001b[0m \u001b[0mbw\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0msel\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msearch\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 10\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'bw:'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mbw\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 11\u001b[0;31m \u001b[0mgwr\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mGWR\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcoords\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0my\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mX\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mbw\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 12\u001b[0m \u001b[0mgwr_results\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mgwr\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfit\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 13\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'aicc:'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mgwr_results\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0maicc\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mNameError\u001b[0m: name 'GWR' is not defined"
]
}
],
@@ -75,44 +79,9 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
" 4%|▍ | 9/200 [00:01<00:37, 5.10it/s]\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"bw(intercept): 92.0\n",
"bw(foreign): 101.0\n",
"bw(african_amer): 136.0\n",
"bw(rural): 158.0\n",
"aicc: 297.12013812258783\n",
"sigma2: 0.34477258292171475\n",
"ENP(model): 11.36825087269831\n",
"adj_alpha(model): 0.017592855949398047\n",
"critical_t(model): 2.399257840857394\n",
"ENP(intercept): 3.844671080264143\n",
"adj_alpha(intercept): 0.013005013681577365\n",
"critical_t(intercept): 2.512107491068591\n",
"ENP(foreign): 3.513770805151652\n",
"adj_alpha(foreign): 0.014229727199820033\n",
"critical_t(foreign): 2.4788879239423856\n",
"ENP(african_amer): 2.2580525278898254\n",
"adj_alpha(african_amer): 0.022142974701622884\n",
"critical_t(african_amer): 2.3106911297007184\n",
"ENP(rural): 1.7517564593926893\n",
"adj_alpha(rural): 0.028542780437261432\n",
"critical_t(rural): 2.210001836555586\n"
]
}
],
"outputs": [],
"source": [
"X = (X - X.mean(axis=0)) / X.std(axis=0)\n",
"\n",
@@ -152,9 +121,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": []
}
@@ -176,7 +143,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.4"
"version": "3.6.6"
}
},
"nbformat": 4,
3 changes: 2 additions & 1 deletion requirements_tests.txt
Original file line number Diff line number Diff line change
@@ -2,4 +2,5 @@ nose
nose-progressive
nose-exclude
coverage
coveralls
coveralls
pandas

0 comments on commit f77e334

Please sign in to comment.