diff --git a/float_raster/__init__.py b/float_raster/__init__.py index b3bf735..5324115 100644 --- a/float_raster/__init__.py +++ b/float_raster/__init__.py @@ -5,14 +5,7 @@ Module for rasterizing polygons, with float-precision anti-aliasing on See the documentation for float_raster.raster(...) for details. """ -from .float_raster import ( - raster as raster, - find_intersections as find_intersections, - create_vertices as create_vertices, - clip_vertices_to_window as clip_vertices_to_window, - get_raster_parts as get_raster_parts, - ) - +from .float_raster import * __author__ = 'Jan Petykiewicz' __version__ = '0.7' diff --git a/float_raster/float_raster.py b/float_raster/float_raster.py index 26cc4a1..5f1917b 100644 --- a/float_raster/float_raster.py +++ b/float_raster/float_raster.py @@ -4,11 +4,6 @@ from numpy import logical_and, diff, floor, ceil, ones, zeros, hstack, full_like from scipy import sparse -class FloatRasterError(Exception): - """ Custom exception for float_raster """ - pass - - def raster( vertices: ArrayLike, grid_x: ArrayLike, @@ -55,15 +50,15 @@ def raster( def find_intersections( - vertices: NDArray[numpy.floating], - grid_x: NDArray[numpy.floating], - grid_y: NDArray[numpy.floating], + vertices: NDArray[numpy.float_], + grid_x: NDArray[numpy.float_], + grid_y: NDArray[numpy.float_], ) -> tuple[NDArray[numpy.float64], NDArray[numpy.float64], NDArray[numpy.float64]]: """ Find intersections between a polygon and grid lines """ if vertices.shape[0] != 2: - raise FloatRasterError('vertices must be 2xN') + raise Exception('vertices must be 2xN') min_bounds = floor(vertices.min(axis=1)) max_bounds = ceil(vertices.max(axis=1)) @@ -132,18 +127,18 @@ def find_intersections( def create_vertices( - vertices: NDArray[numpy.floating], - grid_x: NDArray[numpy.floating], - grid_y: NDArray[numpy.floating], + vertices: NDArray[numpy.float_], + grid_x: NDArray[numpy.float_], + grid_y: NDArray[numpy.float_], new_vertex_data: tuple[NDArray[numpy.float64], NDArray[numpy.float64], NDArray[numpy.float64]] | None = None ) -> sparse.coo_matrix: """ Create additional vertices where a polygon crosses gridlines """ if vertices.shape[0] != 2: - raise FloatRasterError('vertices must be 2xN') + raise Exception('vertices must be 2xN') if grid_x.size < 1 or grid_y.size < 1: - raise FloatRasterError('Grid must contain at least one line in each direction?') + raise Exception('Grid must contain at least one line in each direction?') num_poly_vertices = vertices.shape[1] @@ -240,7 +235,7 @@ def get_raster_parts( grid_y = numpy.array(grid_y) if grid_x.size < 2 or grid_y.size < 2: - raise FloatRasterError('Grid must contain at least one full pixel') + raise Exception('Grid must contain at least one full pixel') num_xy_px = numpy.array([grid_x.size, grid_y.size]) - 1 diff --git a/pyproject.toml b/pyproject.toml index e64259d..e9b447d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,9 +14,6 @@ homepage = "https://mpxd.net/code/jan/float_raster" repository = "https://mpxd.net/code/jan/float_raster" keywords = [ "coverage", - "raster", - "anti-alias", - "polygon", ] classifiers = [ "Programming Language :: Python :: 3", @@ -39,44 +36,3 @@ dependencies = [ [tool.hatch.version] path = "float_raster/__init__.py" - - -[tool.ruff] -exclude = [ - ".git", - "dist", - ] -line-length = 145 -indent-width = 4 -lint.dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" -lint.select = [ - "NPY", "E", "F", "W", "B", "ANN", "UP", "SLOT", "SIM", "LOG", - "C4", "ISC", "PIE", "PT", "RET", "TCH", "PTH", "INT", - "ARG", "PL", "R", "TRY", - "G010", "G101", "G201", "G202", - "Q002", "Q003", "Q004", - ] -lint.ignore = [ - #"ANN001", # No annotation - "ANN002", # *args - "ANN003", # **kwargs - "ANN401", # Any - "ANN101", # self: Self - "SIM108", # single-line if / else assignment - "RET504", # x=y+z; return x - "PIE790", # unnecessary pass - "ISC003", # non-implicit string concatenation - "C408", # dict(x=y) instead of {'x': y} - "PLR09", # Too many xxx - "PLR2004", # magic number - "PLC0414", # import x as x - "TRY003", # Long exception message - ] - - -[[tool.mypy.overrides]] -module = [ - "scipy", - "scipy.sparse", - ] -ignore_missing_imports = true