def setUp(self): self.network = copy.deepcopy(network_lattice_1x1_small) # generate synthetic origins obs1 = tigernet.generate_obs(5, self.network.s_data) obs1["obs_id"] = ["a", "b", "c", "d", "e"] # generate synthetic destinations obs2 = tigernet.generate_obs(3, self.network.s_data, seed=1) obs2["obs_id"] = ["z", "y", "x"] # associate origins with the network args = self.network, obs1.copy() kwargs = {"df_name": "obs1", "df_key": "obs_id", "snap_to": "nodes"} self.net_obs1 = tigernet.Observations(*args, **kwargs) # associate destinations with the network args = self.network, obs2.copy() kwargs = {"df_name": "obs2", "df_key": "obs_id", "snap_to": "nodes"} self.net_obs2 = tigernet.Observations(*args, **kwargs)
def setUp(self): network = copy.deepcopy(network_empirical_simplified) # generate synthetic observations obs = tigernet.generate_obs(500, network.s_data) obs["obs_id"] = obs.index # associate observations with the network args = network, obs.copy() kwargs = {"df_name": "obs1", "df_key": "obs_id", "snap_to": "nodes"} self.net_obs = tigernet.Observations(*args, **kwargs)
def setUp(self): network = copy.deepcopy(network_lattice_1x1_geomelem) # generate synthetic observations obs = tigernet.generate_obs(5, network.s_data) obs["obs_id"] = ["a", "b", "c", "d", "e"] # associate observations with the network args = network, obs.copy() kwargs = {"df_name": "obs1", "df_key": "obs_id"} self.net_obs = tigernet.Observations(*args, **kwargs)
def setUp(self): network = copy.deepcopy(network_empirical_simplified) # generate synthetic observations obs = tigernet.generate_obs(500, network.s_data) obs["obs_id"] = obs.index # associate observations with the network args = network, obs.copy() kwargs = {"df_name": "obs1", "df_key": "obs_id", "snap_to": "nodes"} kwargs.update({"restrict_col": "MTFCC"}) kwargs.update({"remove_restricted": ["S1100", "S1630", "S1640"]}) self.net_obs = tigernet.Observations(*args, **kwargs)
def setUp(self): network = copy.deepcopy(network_lattice_1x1_geomelem) network.s_data.loc[1, "MTFCC"] = "S1100" network.s_data.loc[3, "MTFCC"] = "S1100" # generate synthetic observations obs = tigernet.generate_obs(5, network.s_data) obs["obs_id"] = ["a", "b", "c", "d", "e"] # associate observations with the network args = network, obs.copy() kwargs = {"df_name": "obs1", "df_key": "obs_id", "snap_to": "nodes"} kwargs.update({"restrict_col": "MTFCC"}) kwargs.update({"remove_restricted": ["S1100", "S1630", "S1640"]}) self.net_obs = tigernet.Observations(*args, **kwargs)
def test_generate_observations_totalbounds(self): n_obs = 5 obs = tigernet.generate_obs(n_obs, self.network.s_data) known_n_obs = n_obs observed_n_obs = obs.shape[0] self.assertEqual(observed_n_obs, known_n_obs) known_coords = numpy.array([ (4.939321535345923, 6.436704297351775), (5.4248703846447945, 4.903948646972072), (3.8128931940501425, 5.813047017599905), (3.9382849013642325, 8.025957007038718), (8.672964844509263, 3.4509736694319995), ]) observed_coords = numpy.array([(p.x, p.y) for p in obs.geometry]) numpy.testing.assert_array_almost_equal(observed_coords, known_coords)
def test_generate_observations_inbuffer(self): n_obs = 5 obs = tigernet.generate_obs(n_obs, self.network.s_data, near_net=0.5) known_n_obs = n_obs observed_n_obs = obs.shape[0] self.assertEqual(observed_n_obs, known_n_obs) known_coords = numpy.array([ (4.939321535345923, 6.436704297351775), (5.4248703846447945, 4.903948646972072), (7.125525342743981, 4.76005427777614), (4.153314260276387, 7.024762586578099), (4.696634895750645, 3.731957459914712), ]) observed_coords = numpy.array([(p.x, p.y) for p in obs.geometry]) numpy.testing.assert_array_almost_equal(observed_coords, known_coords)
def test_generate_observations_inbuffer(self): n_obs = 500 obs = tigernet.generate_obs(n_obs, self.network.s_data, near_net=30) known_n_obs = n_obs observed_n_obs = obs.shape[0] self.assertEqual(observed_n_obs, known_n_obs) known_coords = numpy.array([ (622571.9108776418, 166711.9648736473), (624474.552580049, 165130.38564160923), (623803.6385443554, 166644.26001242414), (622876.6555154349, 165227.52219813256), (623400.7775349629, 166023.94388077687), ]) observed_coords = numpy.array([(p.x, p.y) for p in obs.geometry])[:5] numpy.testing.assert_array_almost_equal(observed_coords, known_coords, decimal=DECIMAL)
def test_generate_observations_totalbounds(self): n_obs = 500 obs = tigernet.generate_obs(n_obs, self.network.s_data) known_n_obs = n_obs observed_n_obs = obs.shape[0] self.assertEqual(observed_n_obs, known_n_obs) known_coords = numpy.array([ (622974.1796832045, 166162.55760926675), (623169.2985719838, 165632.6814708112), (622521.5219401979, 165946.95826632337), (622571.9108776418, 166711.9648736473), (624474.552580049, 165130.38564160923), ]) observed_coords = numpy.array([(p.x, p.y) for p in obs.geometry])[:5] numpy.testing.assert_array_almost_equal(observed_coords, known_coords, decimal=DECIMAL)