예제 #1
0
def test_trajectory_distances_and_speeds_timestamp_types(timestamp_type):
    objects, traj_offsets = cuspatial.derive_trajectories(
        # object_id
        cudf.Series([0, 0, 1, 1]),
        # xs
        cudf.Series([0.0, 0.001, 0.0, 0.0]),  # 1 meter in x
        # ys
        cudf.Series([0.0, 0.0, 0.0, 0.001]),  # 1 meter in y
        # timestamp
        cudf.Series([0, timestamp_type[1], 0,
                     timestamp_type[1]]).astype(timestamp_type[0]),
    )
    result = cuspatial.trajectory_distances_and_speeds(
        len(traj_offsets),
        objects["object_id"],
        objects["x"],
        objects["y"],
        objects["timestamp"],
    )
    assert_eq(
        result,
        cudf.DataFrame({
            "distance": [1.0, 1.0],
            "speed": [1.0, 1.0]
        }),
        check_names=False,
    )
예제 #2
0
def test_derive_two_trajectories_one_meter_one_second():
    objects, traj_offsets = cuspatial.derive_trajectories(
        [0, 0, 1, 1],  # object_id
        [0.0, 0.001, 0.0, 0.0],  # xs
        [0.0, 0.0, 0.0, 0.001],  # ys
        [0, 1000, 0, 1000],  # timestamp
    )
    result = cuspatial.trajectory_distances_and_speeds(
        len(traj_offsets),
        objects["object_id"],
        objects["x"],
        objects["y"],
        objects["timestamp"],
    )
    assert_eq(result["distance"], cudf.Series([1.0, 1.0]), check_names=False)
    assert_eq(result["speed"], cudf.Series([1.0, 1.0]), check_names=False)
예제 #3
0
def test_trajectory_distances_and_speeds_ones():
    objects, traj_offsets = cuspatial.derive_trajectories(
        [1],
        [1],
        [1],
        [1],  # object_id  # xs  # ys  # timestamp
    )
    result = cuspatial.trajectory_distances_and_speeds(
        len(traj_offsets),
        objects["object_id"],
        objects["x"],
        objects["y"],
        objects["timestamp"],
    )
    assert_eq(result["distance"], cudf.Series([0.0]), check_names=False)
    assert_eq(result["speed"], cudf.Series([0.0]), check_names=False)
예제 #4
0
def test_trajectory_distances_and_speeds_single_trajectory():
    objects, traj_offsets = cuspatial.derive_trajectories(
        [0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2],  # object_id
        [1.0, 2.0, 3.0, 5.0, 7.0, 1.0, 2.0, 3.0, 6.0, 0.0, 3.0, 6.0],  # xs
        [0.0, 1.0, 2.0, 3.0, 1.0, 3.0, 5.0, 6.0, 5.0, 4.0, 7.0, 4.0],  # ys
        [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],  # timestamp
    )
    result = cuspatial.trajectory_distances_and_speeds(
        len(traj_offsets),
        objects["object_id"],
        objects["x"],
        objects["y"],
        objects["timestamp"],
    )
    assert_eq(
        result["distance"],
        cudf.Series([7892.922363, 6812.55908203125, 8485.28125]),
        check_names=False,
    )
    assert_eq(
        result["speed"],
        cudf.Series([1973230.625, 2270853.0, 4242640.5]),
        check_names=False,
    )  # fast!