File: test_conversion.py

package info (click to toggle)
python-laspy 2.5.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,928 kB
  • sloc: python: 9,065; makefile: 20
file content (27 lines) | stat: -rw-r--r-- 1,008 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import numpy as np
import pytest

import laspy
from laspy.lib import write_then_read_again


@pytest.mark.parametrize("target_point_format_id", [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
def test_point_format_conversion_copies_field_values(file_path, target_point_format_id):
    original = laspy.read(file_path)
    converted = laspy.convert(original, point_format_id=target_point_format_id)
    converted = write_then_read_again(converted)

    converted_dimension_names = set(converted.point_format.dimension_names)
    dimension_expected_to_be_kept = [
        dim_name
        for dim_name in original.point_format.dimension_names
        if dim_name in converted_dimension_names
    ]

    for dim_name in dimension_expected_to_be_kept:
        all_close = np.allclose(
            converted[dim_name], original[dim_name]
        )
        if not all_close and dim_name == "gps_time":
            pytest.xfail("known weirdness of gps_time dimension")
        assert all_close, "{} not equal".format(dim_name)