Skip to content

Commit

Permalink
style: Fix pointless-string-statement / W0105 (#4872)
Browse files Browse the repository at this point in the history
* style: Fix pointless-string-statement / W0105

Change useless string statement with a comment

Pylint rule: https://pylint.readthedocs.io/en/latest/user_guide/messages/warning/pointless-string-statement.html

* Update plots.py
  • Loading branch information
echoix authored Dec 23, 2024
1 parent 3973a58 commit 8f3b891
Show file tree
Hide file tree
Showing 32 changed files with 176 additions and 187 deletions.
18 changes: 8 additions & 10 deletions gui/wxpython/core/globalvar.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,12 @@ def CheckForWx():
import wx.lib.flatnotebook as FN


"""
Query layer (generated for example by selecting item in the Attribute Table Manager)
Deleted automatically on re-render action
"""
# Query layer (generated for example by selecting item in the Attribute Table Manager)
# Deleted automatically on re-render action
# temporal query layer (removed on re-render action)
QUERYLAYER = "qlayer"

"""Style definition for FlatNotebook pages"""
# Style definition for FlatNotebook pages
FNPageStyle = (
FN.FNB_NODRAG
| FN.FNB_TABS_BORDER_SIMPLE
Expand All @@ -143,7 +141,7 @@ def CheckForWx():
FN.FNB_BOTTOM | FN.FNB_NODRAG | FN.FNB_NO_NAV_BUTTONS | FN.FNB_NO_X_BUTTON
)

"""Dialog widget dimension"""
# Dialog widget dimension
DIALOG_SPIN_SIZE = (150, -1)
DIALOG_COMBOBOX_SIZE = (300, -1)
DIALOG_GSELECT_SIZE = (400, -1)
Expand Down Expand Up @@ -234,21 +232,21 @@ def UpdateGRASSAddOnCommands(eList=None):
Debug.msg(1, "Number of GRASS AddOn commands: %d", nCmd)


"""@brief Collected GRASS-related binaries/scripts"""
# Collected GRASS-related binaries/scripts
grassCmd, grassScripts = get_commands()
Debug.msg(1, "Number of core GRASS commands: %d", len(grassCmd))
UpdateGRASSAddOnCommands()

"""@Toolbar icon size"""
# Toolbar icon size
toolbarSize = (24, 24)

"""@Check version of wxPython, use agwStyle for 2.8.11+"""
# Check version of wxPython, use agwStyle for 2.8.11+
hasAgw = CheckWxVersion([2, 8, 11, 0])
wxPythonPhoenix = CheckWxPhoenix()

gtk3 = "gtk3" in wx.PlatformInfo

"""@Add GUIDIR/scripts into path"""
# Add GUIDIR/scripts into path
os.environ["PATH"] = os.path.join(GUIDIR, "scripts") + os.pathsep + os.environ["PATH"]

ignoredCmdPattern = (
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/gcp/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2886,11 +2886,11 @@ def __init__(
size=wx.DefaultSize,
style=wx.DEFAULT_DIALOG_STYLE,
):
wx.Dialog.__init__(self, parent, id, title, pos, size, style)
"""
Dialog to set profile text options: font, title
and font size, axis labels and font size
"""
wx.Dialog.__init__(self, parent, id, title, pos, size, style)
#
# initialize variables
#
Expand Down
3 changes: 1 addition & 2 deletions gui/wxpython/gui_core/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -2186,8 +2186,7 @@ def OnSetOutputFont(self, event):

dlg = wx.FontDialog(self, fontdata)

"FIXME: native font dialog does not initialize with current font"

# FIXME: native font dialog does not initialize with current font
if dlg.ShowModal() == wx.ID_OK:
outdata = dlg.GetFontData()
font = outdata.GetChosenFont()
Expand Down
35 changes: 18 additions & 17 deletions gui/wxpython/gui_core/vselect.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,23 +371,21 @@ def OnExportMap(self, event):
else:
GError(_("Unable to create a new vector map.\n\nReason: %s") % err)

"""
def SetSelectedCat(self, cats):
# allows setting selected vector categories by list of cats (per line)
info = self.QuerySelectedMap()
if 'Category' not in info:
return
for cat in cats.splitlines():
tmpDict = {}
tmpDict['Category'] = cat
tmpDict['Map'] = info['Map']
tmpDict['Layer'] = info['Layer']
tmpDict['Type'] = '-'
self.AddVecInfo(tmpDict)
self._draw()
"""
# def SetSelectedCat(self, cats):
# # allows setting selected vector categories by list of cats (per line)
# info = self.QuerySelectedMap()
# if "Category" not in info:
# return
#
# for cat in cats.splitlines():
# tmpDict = {}
# tmpDict["Category"] = cat
# tmpDict["Map"] = info["Map"]
# tmpDict["Layer"] = info["Layer"]
# tmpDict["Type"] = "-"
# self.AddVecInfo(tmpDict)
#
# self._draw()


class VectorSelectHighlighter:
Expand All @@ -397,6 +395,9 @@ class VectorSelectHighlighter:
"""

def __init__(self, mapdisp, giface):
"""
:param mapdisp: Map display frame
"""
self.qlayer = None
self.mapdisp = mapdisp
self.giface = giface
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/image2target/ii2t_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2835,11 +2835,11 @@ def __init__(
size=wx.DefaultSize,
style=wx.DEFAULT_DIALOG_STYLE,
):
wx.Dialog.__init__(self, parent, id, title, pos, size, style)
"""
Dialog to set profile text options: font, title
and font size, axis labels and font size
"""
wx.Dialog.__init__(self, parent, id, title, pos, size, style)
#
# initialize variables
#
Expand Down
59 changes: 30 additions & 29 deletions gui/wxpython/iscatt/iscatt_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,35 +727,36 @@ def GetCatsRasts(self):
return cats_rasts


# not used, using iclass_perimeter algorithm instead of scipy convolve2d
"""
def RasterizePolygon(pol, height, min_h, width, min_w):
# Joe Kington
# https://stackoverflow.com/questions/3654289/scipy-create-2d-polygon-mask
#poly_verts = [(1,1), (1,4), (4,4),(4,1), (1,1)]
nx = width
ny = height
x, y = np.meshgrid(np.arange(-0.5 + min_w, nx + 0.5 + min_w, dtype=float),
np.arange(-0.5 + min_h, ny + 0.5 + min_h, dtype=float))
x, y = x.flatten(), y.flatten()
points = np.vstack((x,y)).T
p = Path(pol)
grid = p.contains_points(points)
grid = grid.reshape((ny + 1, nx + 1))
raster = np.zeros((height, width), dtype=np.uint8)#TODO bool
#TODO shift by 0.5
B = np.ones((2,2))/4
raster = convolve2d(grid, B, 'valid')
return raster
"""
# not used, using iclass_perimeter algorithm instead of scipy convolve2d

# def RasterizePolygon(pol, height, min_h, width, min_w):
#
# # Joe Kington
# # https://stackoverflow.com/questions/3654289/scipy-create-2d-polygon-mask
#
# # poly_verts = [(1,1), (1,4), (4,4),(4,1), (1,1)]
#
# nx = width
# ny = height
#
# x, y = np.meshgrid(
# np.arange(-0.5 + min_w, nx + 0.5 + min_w, dtype=float),
# np.arange(-0.5 + min_h, ny + 0.5 + min_h, dtype=float),
# )
# x, y = x.flatten(), y.flatten()
#
# points = np.vstack((x, y)).T
#
# p = Path(pol)
# grid = p.contains_points(points)
# grid = grid.reshape((ny + 1, nx + 1))
# raster = np.zeros((height, width), dtype=np.uint8) # TODO bool
#
# # TODO shift by 0.5
# B = np.ones((2, 2)) / 4
# raster = convolve2d(grid, B, "valid")
#
# return raster


def idScattToidBands(scatt_id, n_bands):
Expand Down
47 changes: 23 additions & 24 deletions gui/wxpython/iscatt/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,30 +513,29 @@ def MergeImg(cats_order, scatts, styles, rend_dt, output_queue):
else:
MergeArrays(merged_img, rend_dt[cat_id]["dt"], styles[cat_id]["opacity"])

"""
# c_img_a = np.memmap(
# grass.tempfile(), dtype="uint16", mode="w+", shape=shape
# )
c_img_a = colored_cat.astype("uint16")[:, :, 3] * styles[cat_id]["opacity"]
# TODO apply strides and there will be no need for loop
# b = as_strided(
# a,
# strides=(0, a.strides[3], a.strides[3], a.strides[3]),
# shape=(3, a.shape[0], a.shape[1]),
# )
for i in range(3):
merged_img[:, :, i] = (
merged_img[:, :, i] * (255 - c_img_a)
+ colored_cat[:, :, i] * c_img_a
) / 255
merged_img[:, :, 3] = (
merged_img[:, :, 3] * (255 - c_img_a) + 255 * c_img_a
) / 255
del c_img_a
"""
# # c_img_a = np.memmap(
# # grass.tempfile(), dtype="uint16", mode="w+", shape=shape
# # )
# c_img_a = colored_cat.astype("uint16")[:,:, 3] * styles[cat_id]["opacity"]
#
# # TODO apply strides and there will be no need for loop
# # b = as_strided(
# # a,
# # strides=(0, a.strides[3], a.strides[3], a.strides[3]),
# # shape=(3, a.shape[0], a.shape[1]),
# # )
#
# for i in range(3):
# merged_img[:, :, i] = (
# merged_img[:, :, i] * (255 - c_img_a)
# + colored_cat[:, :, i] * c_img_a
# ) / 255
# merged_img[:, :, 3] = (
# merged_img[:, :, 3] * (255 - c_img_a) + 255 * c_img_a
# ) / 255
#
# del c_img_a

_rendDtMemmapsToFiles(rend_dt)

merged_img = {"dt": merged_img.filename, "sh": merged_img.shape}
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/photo2image/ip2i_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1978,11 +1978,11 @@ def __init__(
size=wx.DefaultSize,
style=wx.DEFAULT_DIALOG_STYLE,
):
wx.Dialog.__init__(self, parent, id, title, pos, size, style)
"""
Dialog to set profile text options: font, title
and font size, axis labels and font size
"""
wx.Dialog.__init__(self, parent, id, title, pos, size, style)
#
# initialize variables
#
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/rlisetup/sampling_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ def _rectangleDrawn(self):
dlg.Destroy()

elif self.samplingtype != SamplingType.WHOLE:
"""When drawing finished, get region values"""
# When drawing finished, get region values
self.sampleFrameChanged.emit(region=region)


Expand Down
3 changes: 2 additions & 1 deletion python/grass/pygrass/gis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,10 +506,11 @@ def reset(self):

doctest.testmod()

# Remove the generated vector map, if exist
mset = utils.get_mapset_vector(test_vector_name, mapset="")
if mset:
# Remove the generated vector map, if exists
run_command("g.remove", flags="f", type="vector", name=test_vector_name)
mset = utils.get_mapset_raster(test_raster_name, mapset="")
if mset:
# Remove the generated raster map, if exists
run_command("g.remove", flags="f", type="raster", name=test_raster_name)
2 changes: 1 addition & 1 deletion python/grass/pygrass/gis/region.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ def set_bbox(self, bbox):

doctest.testmod()

"""Remove the generated vector map, if exist"""
# Remove the generated vector map, if exists
mset = utils.get_mapset_vector(test_vector_name, mapset="")
if mset:
run_command("g.remove", flags="f", type="vector", name=test_vector_name)
Expand Down
3 changes: 2 additions & 1 deletion python/grass/pygrass/raster/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -748,10 +748,11 @@ def numpy2raster(array, mtype, rastname, overwrite=False):

doctest.testmod()

"""Remove the generated vector map, if exist"""
mset = utils.get_mapset_raster(test_raster_name, mapset="")
if mset:
# Remove the generated vector map, if exists
Module("g.remove", flags="f", type="raster", name=test_raster_name)
mset = utils.get_mapset_raster(test_raster_name + "_segment", mapset="")
if mset:
# Remove the generated raster map, if exists
Module("g.remove", flags="f", type="raster", name=test_raster_name + "_segment")
2 changes: 1 addition & 1 deletion python/grass/pygrass/raster/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ def set_cat(self, label, min_cat, max_cat=None, index=None):

doctest.testmod()

"""Remove the generated vector map, if exist"""
mset = utils.get_mapset_raster(test_raster_name, mapset="")
if mset:
# Remove the generated vector map, if exists
Module("g.remove", flags="f", type="raster", name=test_raster_name)
2 changes: 1 addition & 1 deletion python/grass/pygrass/raster/testsuite/test_category.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def setUpClass(cls):

@classmethod
def tearDownClass(cls):
"""Remove the generated vector map, if exist"""
"""Remove the generated vector map, if exists"""
cls.runModule("g.remove", flags="f", type="raster", name=cls.name)
cls.del_temp_region()

Expand Down
2 changes: 1 addition & 1 deletion python/grass/pygrass/raster/testsuite/test_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def setUpClass(cls):

@classmethod
def tearDownClass(cls):
"""Remove the generated vector map, if exist"""
"""Remove the generated vector map, if exists"""
cls.runModule("g.remove", flags="f", type="raster", name=cls.name)
cls.del_temp_region()

Expand Down
2 changes: 1 addition & 1 deletion python/grass/pygrass/raster/testsuite/test_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def setUpClass(cls):

@classmethod
def tearDownClass(cls):
"""Remove the generated vector map, if exist"""
"""Remove the generated vector map, if exists"""
cls.runModule("g.remove", flags="f", type="raster", name=cls.name)
cls.del_temp_region()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def setUpClass(cls):

@classmethod
def tearDownClass(cls):
"""Remove the generated vector map, if exist"""
"""Remove the generated vector map, if exists"""
cls.runModule("g.remove", flags="f", type="raster", name=cls.name)
cls.del_temp_region()

Expand Down
2 changes: 1 addition & 1 deletion python/grass/pygrass/raster/testsuite/test_raster_img.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def setUpClass(cls):

@classmethod
def tearDownClass(cls):
"""Remove the generated vector map, if exist"""
"""Remove the generated vector map, if exists"""
cls.runModule("g.remove", flags="f", type="raster", name=cls.name)
cls.del_temp_region()

Expand Down
Loading

0 comments on commit 8f3b891

Please sign in to comment.