Skip to content

Commit

Permalink
Merge branch 'main' into renovate/ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
echoix committed Nov 11, 2024
2 parents 3259a02 + 8c4f244 commit 0aa1665
Show file tree
Hide file tree
Showing 17 changed files with 122 additions and 823 deletions.
1 change: 0 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ per-file-ignores =
python/grass/temporal/temporal_algebra.py: E722
python/grass/temporal/temporal_granularity.py: E722
python/grass/temporal/temporal_raster_base_algebra.py: E722
python/grass/temporal/temporal_topology_dataset_connector.py: E722
# Current benchmarks/tests are changing sys.path before import.
# Possibly, a different approach should be taken there anyway.
python/grass/pygrass/tests/benchmark.py: E402, F821
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
if: ${{ matrix.language == 'c-cpp' }}

- name: Initialize CodeQL
uses: github/codeql-action/init@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0
uses: github/codeql-action/init@4f3212b61783c3c68e8309a0f18a699764811cda # v3.27.1
with:
languages: ${{ matrix.language }}
config-file: ./.github/codeql/codeql-config.yml
Expand All @@ -81,6 +81,6 @@ jobs:
run: .github/workflows/build_ubuntu-22.04.sh "${HOME}/install"

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0
uses: github/codeql-action/analyze@4f3212b61783c3c68e8309a0f18a699764811cda # v3.27.1
with:
category: "/language:${{matrix.language}}"
2 changes: 1 addition & 1 deletion .github/workflows/python-code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ jobs:
path: bandit.sarif

- name: Upload SARIF File into Security Tab
uses: github/codeql-action/upload-sarif@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0
uses: github/codeql-action/upload-sarif@4f3212b61783c3c68e8309a0f18a699764811cda # v3.27.1
with:
sarif_file: bandit.sarif

Expand Down
10 changes: 10 additions & 0 deletions imagery/i.vi/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,16 @@ int main(int argc, char *argv[])
else
G_fatal_error(_("Unknown color request '%s'"), style);
}
else if (!strcasecmp(viflag, "ndwi")) {
/* apply predefined NDWI color table */
const char *style = "ndwi";

if (G_find_color_rule("ndwi")) {
Rast_make_fp_colors(&colors, style, -1.0, 1.0);
}
else
G_fatal_error(_("Unknown color request '%s'"), style);
}
else {
/* Color from -1.0 to +1.0 in grey */
Rast_init_colors(&colors);
Expand Down
2 changes: 1 addition & 1 deletion lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ include $(MODULE_TOPDIR)/include/Make/Vars.make

#order is relevant:
SUBDIRS = \
external \
datetime \
gis \
proj \
raster \
external \
gmath \
linkm \
driver \
Expand Down
4 changes: 2 additions & 2 deletions lib/gis/file_name.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,13 @@ char *file_name(char *path, const char *dir, const char *element,
const char *name, const char *mapset, const char *base)
{
const char *pname = name;
char xname[GNAME_MAX] = {'\0'};

if (base && *base) {
sprintf(path, "%s", base);
}
else {
char xname[GNAME_MAX];
char xmapset[GMAPSET_MAX];
char xmapset[GMAPSET_MAX] = {'\0'};
char *location = G__location_path();

/*
Expand Down
22 changes: 11 additions & 11 deletions python/grass/temporal/temporal_topology_dataset_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,47 +160,47 @@ def get_number_of_temporal_relations(self):
relations = {}
try:
relations["equal"] = len(self._temporal_topology["EQUAL"])
except:
except KeyError:
relations["equal"] = 0
try:
relations["follows"] = len(self._temporal_topology["FOLLOWS"])
except:
except KeyError:
relations["follows"] = 0
try:
relations["precedes"] = len(self._temporal_topology["PRECEDES"])
except:
except KeyError:
relations["precedes"] = 0
try:
relations["overlaps"] = len(self._temporal_topology["OVERLAPS"])
except:
except KeyError:
relations["overlaps"] = 0
try:
relations["overlapped"] = len(self._temporal_topology["OVERLAPPED"])
except:
except KeyError:
relations["overlapped"] = 0
try:
relations["during"] = len(self._temporal_topology["DURING"])
except:
except KeyError:
relations["during"] = 0
try:
relations["contains"] = len(self._temporal_topology["CONTAINS"])
except:
except KeyError:
relations["contains"] = 0
try:
relations["starts"] = len(self._temporal_topology["STARTS"])
except:
except KeyError:
relations["starts"] = 0
try:
relations["started"] = len(self._temporal_topology["STARTED"])
except:
except KeyError:
relations["started"] = 0
try:
relations["finishes"] = len(self._temporal_topology["FINISHES"])
except:
except KeyError:
relations["finishes"] = 0
try:
relations["finished"] = len(self._temporal_topology["FINISHED"])
except:
except KeyError:
relations["finished"] = 0

return relations
Expand Down
85 changes: 85 additions & 0 deletions raster/r.circle/testsuite/test_circle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
from grass.gunittest.case import TestCase
from grass.gunittest.main import test
import grass.script as gs
from grass.gunittest.gmodules import SimpleModule


class TestRCircle(TestCase):

@classmethod
def setUpClass(cls):
"""Set up a temporary region for testing."""
cls.output = "test_circle"
cls.use_temp_region()
cls.runModule("g.region", n=30, s=0, e=30, w=0, res=10)

@classmethod
def tearDownClass(cls):
"""Clean up after tests."""
cls.del_temp_region()

def tearDown(self):
gs.run_command(
"g.remove",
type="raster",
name=self.output,
flags="f",
)

def test_create_circle_with_b_flag(self):
"""Test creating a binary circle with r.circle using -b flag."""

module = SimpleModule(
"r.circle", output=self.output, coordinates=(15, 15), max=10, flags="b"
)

self.assertModule(module)

self.assertRasterExists(self.output)

self.assertRasterMinMax(
map=self.output,
refmin=1,
refmax=1,
msg="Binary circle should have category value of 1",
)

def test_create_circle_without_b_flag(self):
"""Test creating a circle with r.circle without -b flag."""

module = SimpleModule(
"r.circle", output=self.output, coordinates=(15, 15), max=10
)

self.assertModule(module)

self.assertRasterExists(self.output)

self.assertRasterMinMax(
map=self.output,
refmin=0,
refmax=10,
msg="Circle should have distance values from 0 to 10",
)

def test_create_circle_with_multiplier(self):
"""Test creating a circle with r.circle with a multiplier."""

module = SimpleModule(
"r.circle", output=self.output, coordinates=(15, 15), max=10, multiplier=2
)

self.assertModule(module)

self.assertRasterExists(self.output)

self.assertRasterMinMax(
map=self.output,
refmin=0,
refmax=20,
msg="Circle should have distance values from 0 to 20",
)


if __name__ == "__main__":
test()
Loading

0 comments on commit 0aa1665

Please sign in to comment.