File: test_modif_1_2.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 (79 lines) | stat: -rw-r--r-- 1,846 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import numpy as np
import pytest

import laspy
from tests.test_common import (
    do_compression,
    simple_las,
    simple_laz,
    write_then_read_again,
)


@pytest.fixture(
    params=(
        [simple_las, simple_laz]
        if laspy.LazBackend.detect_available()
        else [simple_las]
    )
)
def las(request):
    return laspy.read(request.param)


def test_classification_overflows(las):
    c = las.classification
    with pytest.raises(OverflowError):
        c[0] = 54


@pytest.mark.parametrize("do_compress", do_compression)
def test_classification_change(las, do_compress):
    c = las.classification
    c[:] = 10

    las.classification = c
    assert np.allclose(c, las.classification)

    las = write_then_read_again(las, do_compress=do_compress)
    assert np.allclose(c, las.classification)


@pytest.mark.parametrize("do_compress", do_compression)
def test_synthetic_change(las, do_compress):
    s = las.synthetic
    s[:] = False
    s[17] = True

    las.synthetic = s
    assert np.allclose(s, las.synthetic)
    las = write_then_read_again(las, do_compress=do_compress)

    assert np.allclose(s, las.synthetic)


@pytest.mark.parametrize("do_compress", do_compression)
def test_key_point_change(las, do_compress):
    kp = las.key_point
    kp[:] = False
    kp[25] = True

    las.key_point = kp
    assert np.allclose(kp, las.key_point)

    las = write_then_read_again(las, do_compress=do_compress)
    assert np.allclose(kp, las.key_point)


@pytest.mark.parametrize("do_compress", do_compression)
def test_withheld_changes(las, do_compress):
    withheld = las.withheld
    withheld[:] = False
    withheld[180] = True

    las.withheld = withheld
    assert np.allclose(withheld, las.withheld)

    las = write_then_read_again(las, do_compress=do_compress)

    assert np.allclose(withheld, las.withheld)