Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build with clang 16 #162

Merged
merged 2 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 32 additions & 16 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,21 +1,37 @@
[flake8]
max_line_length = 88
ignore =
C408 # Unnecessary dict/list/tuple call - rewrite as a literal
E203 # whitespace before ':' - doesn't work well with black
E225 # missing whitespace around operator - let black worry about that
E262 # inline comment should start with '# '
E265 # block comment should start with '# '
E266 # too many leading '#' for block comment
E302 # expected 2 blank lines, found 1
E402 # module level import not at top of file
E501 # line too long - let black handle that
E711 # comparison to None should be
E712 # comparison to False/True should be
E741 # ambiguous variable name
F405 # may be undefined, or defined from star imports
W291 # trailing
W503 # line break occurred before a binary operator - let black worry about that
W504 # line break occurred after a binary operator - let black worry about that
# Unnecessary dict/list/tuple call - rewrite as a literal
C408
# whitespace before ':' - doesn't work well with black
E203
# missing whitespace around operator - let black worry about that
E225
# inline comment should start with '# '
E262
# block comment should start with '# '
E265
# too many leading '#' for block comment
E266
# expected 2 blank lines, found 1
E302
# module level import not at top of file
E402
# line too long - let black handle that
E501
# comparison to None should be
E711
# comparison to False/True should be
E712
# ambiguous variable name
E741
# may be undefined, or defined from star imports
F405
# trailing
W291
# line break occurred before a binary operator - let black worry about that
W503
# line break occurred after a binary operator - let black worry about that
W504
per-file-ignores =
__init__.py:F401
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ repos:
hooks:
- id: isort
- repo: https://github.com/pycqa/flake8
rev: 3.9.2
rev: 7.1.1
hooks:
- id: flake8
- repo: https://github.com/pre-commit/mirrors-clang-format
Expand Down
6 changes: 3 additions & 3 deletions python/src/exactextract/exact_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
def make_raster_names(root: str, nbands: int) -> list:
if root:
if nbands > 1:
return [f"{root}_band_{i+1}" for i in range(nbands)]
return [f"{root}_band_{i + 1}" for i in range(nbands)]
else:
return [f"{root}"]
else:
if nbands > 1:
return [f"band_{i+1}" for i in range(nbands)]
return [f"band_{i + 1}" for i in range(nbands)]
else:
return [""]

Expand Down Expand Up @@ -483,7 +483,7 @@ def status(frac, message):
except ImportError:

def status(frac, message):
print(f"[{frac*100:0.1f}%] {message}")
print(f"[{frac * 100:0.1f}%] {message}")

processor.set_progress_fn(status)
else:
Expand Down
2 changes: 1 addition & 1 deletion src/operation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class OperationImpl : public Operation
return Feature::ValueType::INT64_ARRAY;
}

if constexpr (std::is_same_v<result_type, std::vector<std::size_t>>) {
if constexpr (std::is_same_v<result_type, std::vector<std::uint64_t>>) {
return Feature::ValueType::INT64_ARRAY;
}

Expand Down
2 changes: 1 addition & 1 deletion test/test_feature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ TEMPLATE_TEST_CASE("64-bit int fields", "[feature]", std::int64_t, std::size_t)

TEST_CASE("exception thrown on oversize unsigned int", "[feature]")
{
auto x = static_cast<std::size_t>(std::numeric_limits<std::int64_t>::max()) + 1;
auto x = static_cast<std::uint64_t>(std::numeric_limits<std::int64_t>::max()) + 1;

MapFeature mf;
CHECK_THROWS_WITH(mf.set("field", x), Catch::StartsWith("Value is too large"));
Expand Down
2 changes: 1 addition & 1 deletion test/test_gdal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ TEST_CASE("GDAL feature access", "[gdal]")
feature.set("int64_field", std::int64_t(6000000000));
CHECK(feature.get_int64("int64_field") == 6000000000);
CHECK(feature.field_type("int64_field") == Feature::ValueType::INT64);
CHECK_THROWS(feature.set("int64_field", static_cast<std::size_t>(std::numeric_limits<std::int64_t>::max()) + 100));
CHECK_THROWS(feature.set("int64_field", static_cast<std::uint64_t>(std::numeric_limits<std::int64_t>::max()) + 100));
}

SECTION("double field access")
Expand Down
4 changes: 2 additions & 2 deletions test/test_operation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ TEMPLATE_TEST_CASE("no error if feature does not intersect raster", "[processor]
TEST_CASE("progress callback is called once for each feature", "[processor]")
{
GEOSContextHandle_t context = init_geos();
std::size_t num_features = 3;
int num_features = 3;

Grid<bounded_extent> ex{ { 0, 0, 3, 3 }, 1, 1 }; // 3x3 grid
Matrix<double> values{ { { 9, 1, 1 },
Expand All @@ -308,7 +308,7 @@ TEST_CASE("progress callback is called once for each feature", "[processor]")
MemoryRasterSource value_src(std::move(value_rast));

WKTFeatureSource ds;
for (std::size_t i = 0; i < num_features; i++) {
for (int i = 0; i < num_features; i++) {
MapFeature mf;
mf.set("fid", i);
mf.set_geometry(geos_ptr(context, GEOSGeomFromWKT_r(context, "POLYGON ((0 0, 3 0, 3 3, 0 0))")));
Expand Down
Loading