Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions mgwr/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
__version__ = "1.0.2"

from . import gwr
from . import sel_bw
from . import diagnostics
Expand Down
44 changes: 22 additions & 22 deletions mgwr/tests/test_gwr.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

import os
import libpysal
from libpysal import io
import numpy as np
import unittest
import pickle as pk
Expand All @@ -16,7 +16,7 @@
class TestGWRGaussian(unittest.TestCase):
def setUp(self):
data_path = os.path.join(os.path.dirname(__file__),'georgia/GData_utm.csv')
data = libpysal.open(data_path)
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))
rural = np.array(data.by_col('PctRural')).reshape((-1,1))
Expand All @@ -25,10 +25,10 @@ def setUp(self):
fb = np.array(data.by_col('PctFB')).reshape((-1,1))
self.X = np.hstack([rural, pov, black])
self.mgwr_X = np.hstack([fb, black, rural])
self.BS_F = libpysal.open(os.path.join(os.path.dirname(__file__),'georgia/georgia_BS_F_listwise.csv'))
self.BS_NN = libpysal.open(os.path.join(os.path.dirname(__file__),'georgia/georgia_BS_NN_listwise.csv'))
self.GS_F = libpysal.open(os.path.join(os.path.dirname(__file__),'georgia/georgia_GS_F_listwise.csv'))
self.GS_NN =libpysal.open(os.path.join(os.path.dirname(__file__),'georgia/georgia_GS_NN_listwise.csv'))
self.BS_F = io.open(os.path.join(os.path.dirname(__file__),'georgia/georgia_BS_F_listwise.csv'))
self.BS_NN = io.open(os.path.join(os.path.dirname(__file__),'georgia/georgia_BS_NN_listwise.csv'))
self.GS_F = io.open(os.path.join(os.path.dirname(__file__),'georgia/georgia_GS_F_listwise.csv'))
self.GS_NN = io.open(os.path.join(os.path.dirname(__file__),'georgia/georgia_GS_NN_listwise.csv'))
MGWR_path = os.path.join(os.path.dirname(__file__),'mgwr_example.p')
self.MGWR = pk.load(open(MGWR_path, 'rb'))

Expand Down Expand Up @@ -104,13 +104,13 @@ def test_BS_NN(self):
inf = np.array(self.BS_NN.by_col(' influence')).reshape((-1,1))
cooksD = np.array(self.BS_NN.by_col(' CooksD')).reshape((-1,1))
local_corr = os.path.join(os.path.dirname(__file__),'local_corr.csv')
corr1 = np.array(libpysal.open(local_corr))
corr1 = np.array(io.open(local_corr))
local_vif = os.path.join(os.path.dirname(__file__),'local_vif.csv')
vif1 = np.array(libpysal.open(local_vif))
vif1 = np.array(io.open(local_vif))
local_cn = os.path.join(os.path.dirname(__file__),'local_cn.csv')
cn1 = np.array(libpysal.open(local_cn))
cn1 = np.array(io.open(local_cn))
local_vdp = os.path.join(os.path.dirname(__file__),'local_vdp.csv')
vdp1 = np.array(libpysal.open(local_vdp), dtype=np.float64)
vdp1 = np.array(io.open(local_vdp), dtype=np.float64)
spat_var_p_vals = [0. , 0.0 , 0.5, 0.2]

model = GWR(self.coords, self.y, self.X, bw=90.000, fixed=False,
Expand Down Expand Up @@ -381,7 +381,7 @@ def test_Prediction(self):

def test_BS_NN_longlat(self):
GA_longlat = os.path.join(os.path.dirname(__file__),'ga_bs_nn_longlat_listwise.csv')
self.BS_NN_longlat = libpysal.open(GA_longlat)
self.BS_NN_longlat = io.open(GA_longlat)

coords_longlat = list(zip(self.BS_NN_longlat.by_col(' x_coord'), self.BS_NN_longlat.by_col(' y_coord')))
est_Int = self.BS_NN_longlat.by_col(' est_Intercept')
Expand Down Expand Up @@ -442,7 +442,7 @@ def test_BS_NN_longlat(self):
class TestGWRPoisson(unittest.TestCase):
def setUp(self):
data_path = os.path.join(os.path.dirname(__file__),'tokyo/Tokyomortality.csv')
data = libpysal.open(data_path, mode='Ur')
data = io.open(data_path, mode='Ur')
self.coords = list(zip(data.by_col('X_CENTROID'), data.by_col('Y_CENTROID')))
self.y = np.array(data.by_col('db2564')).reshape((-1,1))
self.off = np.array(data.by_col('eb2564')).reshape((-1,1))
Expand All @@ -451,11 +451,11 @@ def setUp(self):
POP = np.array(data.by_col('POP65')).reshape((-1,1))
UNEMP = np.array(data.by_col('UNEMP')).reshape((-1,1))
self.X = np.hstack([OCC,OWN,POP,UNEMP])
self.BS_F = libpysal.open(os.path.join(os.path.dirname(__file__),'tokyo/tokyo_BS_F_listwise.csv'))
self.BS_NN = libpysal.open(os.path.join(os.path.dirname(__file__),'tokyo/tokyo_BS_NN_listwise.csv'))
self.GS_F = libpysal.open(os.path.join(os.path.dirname(__file__),'tokyo/tokyo_GS_F_listwise.csv'))
self.GS_NN = libpysal.open(os.path.join(os.path.dirname(__file__),'tokyo/tokyo_GS_NN_listwise.csv'))
self.BS_NN_OFF = libpysal.open(os.path.join(os.path.dirname(__file__),'tokyo/tokyo_BS_NN_OFF_listwise.csv'))
self.BS_F = io.open(os.path.join(os.path.dirname(__file__),'tokyo/tokyo_BS_F_listwise.csv'))
self.BS_NN = io.open(os.path.join(os.path.dirname(__file__),'tokyo/tokyo_BS_NN_listwise.csv'))
self.GS_F = io.open(os.path.join(os.path.dirname(__file__),'tokyo/tokyo_GS_F_listwise.csv'))
self.GS_NN = io.open(os.path.join(os.path.dirname(__file__),'tokyo/tokyo_GS_NN_listwise.csv'))
self.BS_NN_OFF = io.open(os.path.join(os.path.dirname(__file__),'tokyo/tokyo_BS_NN_OFF_listwise.csv'))

def test_BS_F(self):
est_Int = self.BS_F.by_col(' est_Intercept')
Expand Down Expand Up @@ -712,7 +712,7 @@ def test_GS_NN(self):
class TestGWRBinomial(unittest.TestCase):
def setUp(self):
data_path = os.path.join(os.path.dirname(__file__),'clearwater/landslides.csv')
data = libpysal.open(data_path)
data = io.open(data_path)
self.coords = list(zip(data.by_col('X'), data.by_col('Y')))
self.y = np.array(data.by_col('Landslid')).reshape((-1,1))
ELEV = np.array(data.by_col('Elev')).reshape((-1,1))
Expand All @@ -722,10 +722,10 @@ def setUp(self):
SOUTH = np.array(data.by_col('AbsSouth')).reshape((-1,1))
DIST = np.array(data.by_col('DistStrm')).reshape((-1,1))
self.X = np.hstack([ELEV, SLOPE, SIN, COS, SOUTH, DIST])
self.BS_F = libpysal.open(os.path.join(os.path.dirname(__file__),'clearwater/clearwater_BS_F_listwise.csv'))
self.BS_NN = libpysal.open(os.path.join(os.path.dirname(__file__),'clearwater/clearwater_BS_NN_listwise.csv'))
self.GS_F = libpysal.open(os.path.join(os.path.dirname(__file__),'clearwater/clearwater_GS_F_listwise.csv'))
self.GS_NN = libpysal.open(os.path.join(os.path.dirname(__file__),'clearwater/clearwater_GS_NN_listwise.csv'))
self.BS_F = io.open(os.path.join(os.path.dirname(__file__),'clearwater/clearwater_BS_F_listwise.csv'))
self.BS_NN = io.open(os.path.join(os.path.dirname(__file__),'clearwater/clearwater_BS_NN_listwise.csv'))
self.GS_F = io.open(os.path.join(os.path.dirname(__file__),'clearwater/clearwater_GS_F_listwise.csv'))
self.GS_NN = io.open(os.path.join(os.path.dirname(__file__),'clearwater/clearwater_GS_NN_listwise.csv'))

def test_BS_F(self):
est_Int = self.BS_F.by_col(' est_Intercept')
Expand Down
5 changes: 3 additions & 2 deletions mgwr/tests/test_sel_bw.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import os
import numpy as np
import libpysal
from libpysal import io
import unittest
from spglm.family import Gaussian, Poisson, Binomial
from ..sel_bw import Sel_BW
Expand All @@ -13,7 +13,8 @@
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 = libpysal.open(data_path)
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))
rural = np.array(data.by_col('PctRural')).reshape((-1,1))
Expand Down
26 changes: 10 additions & 16 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
from setuptools import setup
from distutils.command.build_py import build_py

try:
from distutils.command.build_py import build_py_2to3 as build_py
except ImportError:
from distutils.command.build_py import build_py

Major = 1
Feature = 0
Bug = 2
version = '%d.%d.%d' % (Major, Feature, Bug)
# Get __version__ from PACKAGE_NAME/__init__.py without importing the package
# __version__ has to be defined in the first line
with open('mgwr/__init__.py', 'r') as f:
exec(f.readline())

setup(name='mgwr', #name of package
version=version,
version=__version__,
description='multiscale geographically weighted regression', #short <80chr description
url='https://github.com/TaylorOshan/mgwr', #github repo
url='https://github.com/pysal/mgwr', #github repo
maintainer='Taylor M. Oshan',
maintainer_email='[email protected]',
test_suite = 'nose.collector',
Expand All @@ -28,12 +24,10 @@
'Topic :: Scientific/Engineering :: GIS',
'License :: OSI Approved :: BSD License',
'Programming Language :: Python',
'Programming Language :: Python :: 2.5',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.4'
'Programming Language :: Python :: 3.5'
'Programming Language :: Python :: 3.6'
],
license='3-Clause BSD',
license='2-Clause BSD',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be less of a concern, but is it better to follow the 3-Clause BSD license suggested in the submodule_template?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, that I didn't consider. Should I go ahead and make the change or wait for Taylor's input since he is the maintainer?

Copy link
Member

@weikang9009 weikang9009 Aug 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's wait for Taylor's input!

packages=['mgwr'],
install_requires=['numpy', 'scipy', 'libpysal', 'spglm', 'spreg'],
zip_safe=False,
Expand Down