Skip to content

Commit

Permalink
Merge with main
Browse files Browse the repository at this point in the history
  • Loading branch information
wenzeslaus committed Oct 15, 2024
2 parents fd73444 + f22c9a2 commit c2a0a6f
Show file tree
Hide file tree
Showing 25 changed files with 101 additions and 76 deletions.
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ omit =
${INITIAL_PWD-.}/.github/*
${INITIAL_PWD-.}/bin.*/*
${INITIAL_PWD-.}/dist.*/*
**/gui/wxpython/*/**
**/OBJ.*/*
source =
.
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@c36620d31ac7c881962c3d9dd939c40ec9434f2b # v3.26.12
uses: github/codeql-action/init@f779452ac5af1c261dce0346a8f964149f49322b # v3.26.13
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@c36620d31ac7c881962c3d9dd939c40ec9434f2b # v3.26.12
uses: github/codeql-action/analyze@f779452ac5af1c261dce0346a8f964149f49322b # v3.26.13
with:
category: "/language:${{matrix.language}}"
11 changes: 9 additions & 2 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,25 @@ jobs:
run: |
export PYTHONPATH=`grass --config python_path`:$PYTHONPATH
export LD_LIBRARY_PATH=$(grass --config path)/lib:$LD_LIBRARY_PATH
export INITIAL_GISBASE="$(grass --config path)"
export INITIAL_PWD="${PWD}"
pytest --verbose --color=yes --durations=0 --durations-min=0.5 \
--numprocesses auto -ra . \
--numprocesses auto \
--cov \
--cov-context=test \
-ra . \
-m 'not needs_solo_run'
- name: Run pytest with a single worker (for tests marked with needs_solo_run)
run: |
export PYTHONPATH=`grass --config python_path`:$PYTHONPATH
export LD_LIBRARY_PATH=$(grass --config path)/lib:$LD_LIBRARY_PATH
export INITIAL_GISBASE="$(grass --config path)"
INITIAL_PWD="${PWD}" pytest --verbose --color=yes --durations=0 --durations-min=0.5 \
export INITIAL_PWD="${PWD}"
pytest --verbose --color=yes --durations=0 --durations-min=0.5 \
--cov \
--cov-context=test \
--cov-append \
-ra . \
-m 'needs_solo_run'
- name: Fix non-standard installed script paths in coverage data
Expand Down
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@c36620d31ac7c881962c3d9dd939c40ec9434f2b # v3.26.12
uses: github/codeql-action/upload-sarif@f779452ac5af1c261dce0346a8f964149f49322b # v3.26.13
with:
sarif_file: bandit.sarif

Expand Down
4 changes: 3 additions & 1 deletion gui/wxpython/lmgr/giface.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ def __init__(self, tree):
self._tree = tree

def __len__(self):
return len(list(self))
# The list constructor calls __len__ as an optimization if available,
# causing a RecursionError
return len([layer for layer in self]) # noqa: C416

def __iter__(self):
"""Iterates over the contents of the list."""
Expand Down
5 changes: 3 additions & 2 deletions imagery/i.fft/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@ int main(int argc, char *argv[])
inputfd = Rast_open_old(Cellmap_orig, "");

if (Rast_maskfd() >= 0)
G_warning(_("Raster MASK found, consider to remove "
"(see man-page). Will continue..."));
G_warning(_("Raster mask active, consider removing it"
" and running again without it (see documentation for"
" details). This current process will now continue..."));

G_get_set_window(&window); /* get the current window for later */

Expand Down
2 changes: 1 addition & 1 deletion imagery/i.pca/i.pca.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ <h2>DESCRIPTION</h2>
principal component with the highest importance.

<p>
The current geographic region definition and MASK settings are
The current geographic region definition and raster mask settings are
respected when reading the input raster map layers. When the rescale
option is used, the output files are rescaled to fit the min,max range.

Expand Down
4 changes: 2 additions & 2 deletions lib/ogsf/gk.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ void gk_follow_frames(Viewnode *view, int numsteps, Keylist *keys, int step,

GS_get_from(tmp);
G_debug(3, "gk_follow_frames():");
G_debug(3, " MASK: %lx", mask);
G_debug(3, " FROM: %f %f %f", tmp[X], tmp[Y], tmp[Z]);
G_debug(3, " mask: %lx", mask);
G_debug(3, " from: %f %f %f", tmp[X], tmp[Y], tmp[Z]);

/* ACS 1 line: was GS_get_focus(tmp);
with this kanimator works also for flythrough navigation
Expand Down
2 changes: 1 addition & 1 deletion lib/ogsf/gvd.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ int gvd_vect(geovect *gv, geosurf *gs, int do_fast)
}
gsd_endline();
}
/* need to handle MASK! */
/* need to handle mask! */
else if (src == CONST_ATT) {
/* for now - but later, do seg intersect maskedge */
if (gs_point_is_masked(gs, bgn) ||
Expand Down
2 changes: 1 addition & 1 deletion lib/raster/mask_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ int Rast__mask_info(char *name, char *mapset)
char rname[GNAME_MAX], rmapset[GMAPSET_MAX];

strcpy(rname, "MASK");
strcpy(rmapset, G_mapset());
(void)G_strlcpy(rmapset, G_mapset(), GMAPSET_MAX);

if (!G_find_raster(rname, rmapset))
return -1;
Expand Down
22 changes: 13 additions & 9 deletions lib/vector/Vlib/geos.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ GEOSCoordSequence *V1_read_line_geos(struct Map_info *Map, long offset,
long size;
double *x, *y, *z;

GEOSCoordSequence *pseq;
GEOSCoordSequence *pseq = NULL;

G_debug(3, "V1_read_line_geos(): offset = %ld", offset);

Expand Down Expand Up @@ -353,26 +353,29 @@ GEOSCoordSequence *V1_read_line_geos(struct Map_info *Map, long offset,
G_debug(3, " n_points = %d dim = %d", n_points,
(Map->head.with_z) ? 3 : 2);

pseq = GEOSCoordSeq_create(n_points, (Map->head.with_z) ? 3 : 2);

x = (double *)G_malloc(n_points * sizeof(double));
y = (double *)G_malloc(n_points * sizeof(double));
if (Map->head.with_z)
z = (double *)G_malloc(n_points * sizeof(double));
else
z = NULL;

if (0 >= dig__fread_port_D(x, n_points, &(Map->dig_fp)))
return NULL; /* end of file */
if (0 >= dig__fread_port_D(x, n_points, &(Map->dig_fp))) {
goto free_return; /* end of file */
}

if (0 >= dig__fread_port_D(y, n_points, &(Map->dig_fp)))
return NULL; /* end of file */
if (0 >= dig__fread_port_D(y, n_points, &(Map->dig_fp))) {
goto free_return; /* end of file */
}

if (Map->head.with_z) {
if (0 >= dig__fread_port_D(z, n_points, &(Map->dig_fp)))
return NULL; /* end of file */
if (0 >= dig__fread_port_D(z, n_points, &(Map->dig_fp))) {
goto free_return; /* end of file */
}
}

pseq = GEOSCoordSeq_create(n_points, (Map->head.with_z) ? 3 : 2);

for (i = 0; i < n_points; i++) {
GEOSCoordSeq_setX(pseq, i, x[i]);
GEOSCoordSeq_setY(pseq, i, y[i]);
Expand All @@ -382,6 +385,7 @@ GEOSCoordSequence *V1_read_line_geos(struct Map_info *Map, long offset,

G_debug(3, " off = %ld", (long)dig_ftell(&(Map->dig_fp)));

free_return:
G_free((void *)x);
G_free((void *)y);
if (z)
Expand Down
1 change: 1 addition & 0 deletions lib/vector/Vlib/open.c
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@ int Vect__open_old(struct Map_info *Map, const char *name, const char *mapset,
if (access(file_path, F_OK) == 0) /* fidx file exists? */
unlink(file_path);
}
Map->support_updated = TRUE;
}

return level;
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ ignore = [
"PLW1641", # eq-without-hash
"PLW2901", # redefined-loop-name
"PLW3201", # bad-dunder-method-name
"PT004", # pytest-missing-fixture-name-underscore # deprecated, so doesn't appear with --preview
"PTH100", # os-path-abspath
"PTH101", # os-chmod
"PTH102", # os-mkdir
Expand Down
21 changes: 8 additions & 13 deletions python/grass/pygrass/vector/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,14 +457,14 @@ def close(self, build=False):
if hasattr(self, "table") and self.table is not None:
self.table.conn.close()
if self.is_open():
if libvect.Vect_close(self.c_mapinfo) != 0:
str_err = "Error when trying to close the map with Vect_close"
raise GrassError(str_err)
if (
self.c_mapinfo.contents.mode
in {libvect.GV_MODE_RW, libvect.GV_MODE_WRITE}
) and build:
self.build()
if libvect.Vect_close(self.c_mapinfo) != 0:
str_err = "Error when trying to close the map with Vect_close"
raise GrassError(str_err)

def remove(self):
"""Remove vector map"""
Expand All @@ -474,16 +474,11 @@ def remove(self):

def build(self):
"""Close the vector map and build vector Topology"""
self.close()
libvect.Vect_set_open_level(1)
if libvect.Vect_open_old2(self.c_mapinfo, self.name, self.mapset, "0") != 1:
str_err = "Error when trying to open the vector map."
raise GrassError(str_err)
# Vect_build returns 1 on success and 0 on error (bool approach)
if libvect.Vect_build(self.c_mapinfo) != 1:
str_err = "Error when trying build topology with Vect_build"
raise GrassError(str_err)
libvect.Vect_close(self.c_mapinfo)
if self.is_open():
# Vect_build returns 1 on success and 0 on error (bool approach)
if libvect.Vect_build(self.c_mapinfo) != 1:
str_err = "Error when trying build topology with Vect_build"
raise GrassError(str_err)


if __name__ == "__main__":
Expand Down
8 changes: 4 additions & 4 deletions raster/r.fill.dir/r.fill.dir.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ <h2>DESCRIPTION</h2>
attributes required by other hydrological models.

<p>
As any GRASS GIS module, <em>r.fill.dir</em> is sensitive to the
computational region settings. Thus
As any GRASS GIS module, <em>r.fill.dir</em> respects the
computational region settings. Thus,
the module can be used to generate a flow direction map for any
sub-area within the full map layer. Also, <em>r.fill.dir</em> is
sensitive to any raster <em>MASK</em> in effect.
sub-area within the full raster map layer. Also, <em>r.fill.dir</em>
will take into account an active raster mask.

<h2>NOTES</h2>

Expand Down
7 changes: 4 additions & 3 deletions raster/r.li/TODO
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ d.vect forests type=boundary

######## TODO: CHECK THIS:

# MASK test
g.copy rast=fields,MASK
# Test with raster mask
r.mask raster=fields
r.li.patchdensity forests conf=movwindow7 output=forests_p_dens7mask --o
d.erase
d.rast.leg forests_p_dens7mask
# -> no negative values! but MASK is respected
r.mask -r
# -> no negative values! but mask is respected

# zero data test
r.mapcalc "forests = 0"
Expand Down
2 changes: 2 additions & 0 deletions raster/r.mask.status/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ int report_status(struct Parameters *params)
else
json_object_set_null(root_object, "is_reclass_of");
char *serialized_string = json_serialize_to_string_pretty(root_value);
if (!serialized_string)
G_fatal_error(_("Failed to initialize pretty JSON string."));
puts(serialized_string);
json_free_serialized_string(serialized_string);
json_value_free(root_value);
Expand Down
2 changes: 2 additions & 0 deletions raster/r.sim/r.sim.sediment/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,8 @@ int main(int argc, char *argv[])
G_message(_("Using metric conversion factor %f, step=%f"), wp.conv,
wp.step);

wp.observation = parm.observation->answer;
wp.logfile = parm.logfile->answer;
init_library_globals(&wp);

if ((wp.tc == NULL) && (wp.et == NULL) && (wp.conc == NULL) &&
Expand Down
4 changes: 3 additions & 1 deletion raster/r.sim/r.sim.water/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ int main(int argc, char *argv[])
parm.logfile->required = NO;
parm.logfile->description =
_("Name for sampling points output text file. For each observation "
"vector point the time series of sediment transport is stored.");
"vector point the time series of water discharge is stored.");
parm.logfile->guisection = _("Output");

parm.nwalk = G_define_option();
Expand Down Expand Up @@ -525,6 +525,8 @@ int main(int argc, char *argv[])
G_message(_("Using metric conversion factor %f, step=%f"), wp.conv,
wp.step);

wp.observation = parm.observation->answer;
wp.logfile = parm.logfile->answer;
init_library_globals(&wp);

if ((wp.depth == NULL) && (wp.disch == NULL) && (wp.err == NULL))
Expand Down
3 changes: 0 additions & 3 deletions raster/r.sim/simlib/hydro.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,6 @@ void main_loop(void)
maxwa = maxwa / nblock;
}

/* Create the observation points */
create_observation_points();

G_debug(2, " maxwa, nblock %d %d", maxwa, nblock);

for (iblock = 1; iblock <= nblock; iblock++) {
Expand Down
2 changes: 1 addition & 1 deletion raster/r.univar/r.univar.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ <h3>PERFORMANCE</h3>
<p>
<em>r.univar</em> supports parallel processing using OpenMP. The user
can specify the number of threads to be used with the <b>nprocs</b> parameter.
However, parallelization is disabled when the MASK is set.
However, parallelization is disabled when the raster mask is set.

<p>
Due to the differences in summation order, users may encounter small floating points
Expand Down
Loading

0 comments on commit c2a0a6f

Please sign in to comment.