Skip to content
This repository has been archived by the owner on Aug 18, 2022. It is now read-only.

Commit

Permalink
Merge branch 'travis-test'
Browse files Browse the repository at this point in the history
  • Loading branch information
tmontaigu committed Jun 20, 2018
2 parents b0f7fa8 + 18dcda0 commit 7334406
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 9 deletions.
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
language: python
python:
- "3.6"

install:
- pip install -r requirements.txt
- pip install lazperf

script:
- pytest pylastests
- pytest pylas # doctests
12 changes: 9 additions & 3 deletions pylas/compression.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def compress_buffer(uncompressed_buffer, record_schema, offset):
return compressed


def _pass_through_laszip(stream, action="decompress"):
def find_laszip_executable():
laszip_names = ("laszip", "laszip.exe", "laszip-cli", "laszip-cli.exe")

for binary in laszip_names:
Expand All @@ -97,9 +97,15 @@ def _pass_through_laszip(stream, action="decompress"):
for x in os.environ["PATH"].split(os.pathsep)
)
if any(in_path):
laszip_binary = binary
break
return binary

else:
return None


def _pass_through_laszip(stream, action="decompress"):
laszip_binary = find_laszip_executable()
if laszip_binary is None:
raise FileNotFoundError("Could not find laszip executable")

if action == "decompress":
Expand Down
6 changes: 6 additions & 0 deletions pylas/lasdatas/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,13 @@ def __getattr__(self, item):
def __setattr__(self, key, value):
""" This is called on every access to an attribute of the instance.
Again we use this to forward the call the the points record
But this time checking if the key is actually a dimension name
so that an error is raised if the user tries to set a valid
LAS dimension even if it is not present in the field.
eg: user tries to set the red field of a file with point format 0:
an error is raised
"""
if key in dims.DIMENSIONS or key in self.points_data.all_dimensions_names:
self.points_data[key] = value
Expand Down
20 changes: 14 additions & 6 deletions pylastests/test_extrabytes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import pytest

import pylas
from pylas.compression import find_laszip_executable

from pylastests.test_common import (
test1_4_las,
extra_bytes_las,
Expand All @@ -10,8 +12,14 @@
simple_las,
)

extra_bytes_files = [extra_bytes_las]
# Because currently lazperf cannot decompress 1.4 file with extra dim
# and Travis CI doesn't have laszip installed
if find_laszip_executable() is not None:
extra_bytes_files.append(extra_bytes_laz)


@pytest.fixture(params=[extra_bytes_las, extra_bytes_laz])
@pytest.fixture(params=extra_bytes_files)
def extrab_las(request):
return pylas.read(request.param)

Expand Down Expand Up @@ -50,10 +58,10 @@ def test_add_extra_bytes(las1_4):
las1_4.test_array[:, 1] = 2.2
las1_4.test_array[:, 2] = 333.6

assert np.alltrue(las1_4.points_data['test_dim'] == 150)
assert np.allclose(las1_4.points_data['test_array'][:, 0], 1.1)
assert np.allclose(las1_4.points_data['test_array'][:, 1], 2.2)
assert np.allclose(las1_4.points_data['test_array'][:, 2], 333.6)
assert np.alltrue(las1_4.points_data["test_dim"] == 150)
assert np.allclose(las1_4.points_data["test_array"][:, 0], 1.1)
assert np.allclose(las1_4.points_data["test_array"][:, 1], 2.2)
assert np.allclose(las1_4.points_data["test_array"][:, 2], 333.6)

las1_4 = write_then_read_again(las1_4)

Expand All @@ -66,7 +74,7 @@ def test_add_extra_bytes(las1_4):
def test_extra_bytes_well_saved(extrab_las):
extrab_las.Time = np.zeros_like(extrab_las.Time)

assert np.alltrue(extrab_las.points_data['Time'] == 0)
assert np.alltrue(extrab_las.points_data["Time"] == 0)

extrab_las = write_then_read_again(extrab_las)

Expand Down

0 comments on commit 7334406

Please sign in to comment.