def test_regular_lattice(self): # 4x4 regular lattice with the exterior known = [P00, P10] bounds = (0, 0, 3, 3) lattice = self.spaghetti.regular_lattice(bounds, 2, nv=2, exterior=True) observed = lattice[0].vertices self.assertEqual(observed, known) # 5x5 regular lattice without the exterior known = [P33, P34] bounds = (0, 0, 4, 4) lattice = self.spaghetti.regular_lattice(bounds, 3, exterior=False) observed = lattice[-1].vertices self.assertEqual(observed, known) # 7x9 regular lattice from shapefile bounds known_vertices = [ (723414.3683108028, 875929.0396895551), (724286.1381211297, 875929.0396895551), ] shp = io.open(STREETS) lattice = self.spaghetti.regular_lattice(shp.bbox, 5, nv=7, exterior=True) observed_vertices = lattice[0].vertices for observed, known in zip(observed_vertices, known_vertices): self.assertEqual((observed[0], observed[1]), known) # test for Type Error with self.assertRaises(TypeError): self.spaghetti.regular_lattice(bounds, [[4]]) # test for Runtime Error with self.assertRaises(RuntimeError): self.spaghetti.regular_lattice((0, 0, 1), 1)
def setUp(self): 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)) rural = np.array(data.by_col('PctRural')).reshape((-1, 1)) pov = np.array(data.by_col('PctPov')).reshape((-1, 1)) black = np.array(data.by_col('PctBlack')).reshape((-1, 1)) 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])
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)) pov = np.array(data.by_col('PctPov')).reshape((-1,1)) black = np.array(data.by_col('PctBlack')).reshape((-1,1)) 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])
def setUp(self): data_path = os.path.join(os.path.dirname(__file__), 'tokyo/Tokyomortality.csv') 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)) OCC = np.array(data.by_col('OCC_TEC')).reshape((-1, 1)) OWN = np.array(data.by_col('OWNH')).reshape((-1, 1)) 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])