def test_target_number_matches_neighborhood_number(self): _, points = create_points_in_xy_grid(lambda x, y: 10 * (x % 2)) environment_point_cloud = create_point_cloud(points[:, 0], points[:, 1], points[:, 2]) assert_target_number_matches_neighborhood_number( environment_point_cloud)
def test_cell_grid(self): _, points = create_points_in_xy_grid(lambda x, y: np.random.rand()) point_cloud = create_point_cloud(points[:, 0], points[:, 1], points[:, 2]) targets = create_point_cloud(np.array([4.5]), np.array([4.5]), np.array([4.5])) # Center of grid neighborhoods = compute_neighborhoods(point_cloud, targets, Cell(2)) neighborhood = next(neighborhoods) assert_equal(len(neighborhood[0]), 4)
def assert_std_for_z_function_in_xy_grid(z_checkered, expected): """Assert that the standard deviation of z values in a grid of unit x and y""" n_points, points = create_points_in_xy_grid(z_checkered) point_cloud = create_point_cloud(points[:, 0], points[:, 1], points[:, 2]) targets = create_point_cloud([0], [0], [0]) compute_features(point_cloud, [range(n_points)], 0, targets, ['sigma_z'], InfiniteCylinder(10)) np.testing.assert_almost_equal(targets[keys.point]['sigma_z']['data'][0], expected)
def test_cell_grid_origin(self): _, points = create_points_in_xy_grid(lambda x, y: np.random.rand()) point_cloud = create_point_cloud(points[:, 0], points[:, 1], points[:, 2]) targets = create_point_cloud(np.array([0]), np.array([0]), np.array([0])) # Center of grid neighborhoods = list( compute_neighborhoods(point_cloud, targets, Cell(1.99))) assert_equal(len(neighborhoods[0]), 1)
def test_cube_grid(self): _, points = create_points_in_xy_grid(lambda x, y: 10 * (x % 2)) point_cloud = create_point_cloud(points[:, 0], points[:, 1], points[:, 2]) targets = create_point_cloud(np.array([4.5]), np.array([4.5]), np.array([0])) # Center of grid neighborhoods = list( compute_neighborhoods(point_cloud, targets, Cube(2))) assert_equal(len(neighborhoods[0]), 2)
def test_cell_grid_larger_sample_size(self): _, points = create_points_in_xy_grid(lambda x, y: np.random.rand()) point_cloud = create_point_cloud(points[:, 0], points[:, 1], points[:, 2]) targets = create_point_cloud(np.array([4.5]), np.array([4.5]), np.array([4.5])) # Center of grid neighborhoods = compute_neighborhoods( point_cloud, targets, Cell(5), sample_size=10000) # Result 36 neighbors _ = next(neighborhoods)