diff --git a/.github/workflows/run-unit-tests_conda-forge.yml b/.github/workflows/run-unit-tests_conda-forge.yml index 7a0ef70..2fc82a4 100644 --- a/.github/workflows/run-unit-tests_conda-forge.yml +++ b/.github/workflows/run-unit-tests_conda-forge.yml @@ -33,6 +33,9 @@ jobs: conda-solver: libmamba - name: Install dependencies + # Note that conda-forge OpenCV 4.9 package has *GL dependencies that are not satisfied by + # GitHub's Ubuntu image, so 'opencv-python-headless' is installed with pip below. + # TODO: change this if a headless conda-forge version becomes available run: | conda info conda install -c conda-forge rasterio click tqdm pyyaml fsspec requests aiohttp pytest pytest-cov diff --git a/orthority/__init__.py b/orthority/__init__.py index 99c57c0..aa672fa 100644 --- a/orthority/__init__.py +++ b/orthority/__init__.py @@ -14,18 +14,20 @@ # If not, see . """Orthorectification toolkit.""" -import logging import os -import pathlib # enable on-demand download and caching of proj transformation grids (NB must be done before # importing rasterio) os.environ.update(PROJ_NETWORK='ON') +import logging +import pathlib + from orthority.enums import Compress, Interp from orthority.factory import FrameCameras, RpcCameras from orthority.ortho import Ortho + # Add a NullHandler to the package logger to hide logs by default. Applications can then add # their own handler(s). log = logging.getLogger(__name__) diff --git a/orthority/cli.py b/orthority/cli.py index b319ff5..7458ac5 100644 --- a/orthority/cli.py +++ b/orthority/cli.py @@ -1193,6 +1193,4 @@ def simple_ortho(argv=None): if __name__ == '__main__': cli() -# TODO: test CLI exceptions are meaningful - ## diff --git a/tests/__init__.py b/tests/__init__.py index e69de29..d87fb2d 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -0,0 +1,20 @@ +# Copyright The Orthority Contributors. +# +# This file is part of Orthority. +# +# Orthority is free software: you can redistribute it and/or modify it under the terms of the GNU +# Affero General Public License as published by the Free Software Foundation, either version 3 of +# the License, or (at your option) any later version. +# +# Orthority is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License along with Orthority. +# If not, see . + +# enable on-demand download and caching of proj transformation grids (NB must be done before +# importing rasterio) +import os + +os.environ.update(PROJ_NETWORK='ON') diff --git a/tests/test_camera.py b/tests/test_camera.py index d9d7190..4ba254c 100644 --- a/tests/test_camera.py +++ b/tests/test_camera.py @@ -15,28 +15,23 @@ from __future__ import annotations +from pathlib import Path +from typing import Sequence + +import cv2 import numpy as np import pytest -from pathlib import Path import rasterio as rio -import cv2 from rasterio.transform import from_bounds -from typing import Sequence +from orthority import utils from orthority.camera import ( - BrownCamera, - Camera, - create_camera, - FisheyeCamera, - FrameCamera, - OpenCVCamera, - PinholeCamera, + BrownCamera, Camera, create_camera, FisheyeCamera, FrameCamera, OpenCVCamera, PinholeCamera, RpcCamera, ) from orthority.enums import CameraType, Interp from orthority.errors import CameraInitError, OrthorityWarning -from tests.conftest import _dem_offset, _dem_gain, checkerboard, ortho_bounds, create_zsurf -from orthority import utils +from tests.conftest import _dem_offset, checkerboard, create_zsurf, ortho_bounds @pytest.mark.parametrize( @@ -129,13 +124,14 @@ def test_frame_update(im_size: tuple, focal_len: float, sensor_size: tuple, xyz: assert np.all(camera._R != 0) -@pytest.mark.parametrize('cam_type', - [CameraType.pinhole, CameraType.opencv, CameraType.brown, CameraType.fisheye] +@pytest.mark.parametrize( + 'cam_type', [CameraType.pinhole, CameraType.opencv, CameraType.brown, CameraType.fisheye] ) def test_frame_update_error( cam_type: CameraType, im_size: tuple, focal_len: float, sensor_size: tuple ): - """Test an error is raised if a ``FrameCamera`` is used before initialising exterior parameters. + """Test an error is raised if a ``FrameCamera`` is used before initialising exterior + parameters. """ camera = create_camera(cam_type, im_size, focal_len, sensor_size=sensor_size) @@ -874,9 +870,7 @@ def test_frame_world_boundary_equiv(camera: str, camera_und: str, request: pytes assert xyz == pytest.approx(xyz_und, abs=1e-6) -@pytest.mark.parametrize( - 'camera', ['pinhole_camera', 'rpc_camera'] -) +@pytest.mark.parametrize('camera', ['pinhole_camera', 'rpc_camera']) def test_world_boundary_errors(camera: str, request: pytest.FixtureRequest): """Test ``Camera.world_boundary()`` error conditions.""" camera: Camera = request.getfixturevalue(camera)