Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swap to libpysal.io.open #26

Closed
wants to merge 1 commit into from
Closed
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
42 changes: 21 additions & 21 deletions mgwr/tests/test_gwr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = libpysal.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 = libpysal.io.open(os.path.join(os.path.dirname(__file__),'georgia/georgia_BS_F_listwise.csv'))
self.BS_NN = libpysal.io.open(os.path.join(os.path.dirname(__file__),'georgia/georgia_BS_NN_listwise.csv'))
self.GS_F = libpysal.io.open(os.path.join(os.path.dirname(__file__),'georgia/georgia_GS_F_listwise.csv'))
self.GS_NN =libpysal.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(libpysal.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(libpysal.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(libpysal.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(libpysal.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 = libpysal.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 = libpysal.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 = libpysal.io.open(os.path.join(os.path.dirname(__file__),'tokyo/tokyo_BS_F_listwise.csv'))
self.BS_NN = libpysal.io.open(os.path.join(os.path.dirname(__file__),'tokyo/tokyo_BS_NN_listwise.csv'))
self.GS_F = libpysal.io.open(os.path.join(os.path.dirname(__file__),'tokyo/tokyo_GS_F_listwise.csv'))
self.GS_NN = libpysal.io.open(os.path.join(os.path.dirname(__file__),'tokyo/tokyo_GS_NN_listwise.csv'))
self.BS_NN_OFF = libpysal.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 = libpysal.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 = libpysal.io.open(os.path.join(os.path.dirname(__file__),'clearwater/clearwater_BS_F_listwise.csv'))
self.BS_NN = libpysal.io.open(os.path.join(os.path.dirname(__file__),'clearwater/clearwater_BS_NN_listwise.csv'))
self.GS_F = libpysal.io.open(os.path.join(os.path.dirname(__file__),'clearwater/clearwater_GS_F_listwise.csv'))
self.GS_NN = libpysal.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
2 changes: 1 addition & 1 deletion mgwr/tests/test_sel_bw.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
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.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