pep8: Some modifications to respect pep8 standard code.

This commit is contained in:
Pierre-Antoine Rouby committed 2023-10-11 11:06:45 +02:00
1 parent 8544dd1144
commit fa2454d079
152 files changed
+1626 -1277

No files matched your search

+10 -10
View File
@@ -33,16 +33,17 @@ _translate = QCoreApplication.translate
logger = logging.getLogger()
class Plot(PamhyrPlot):
def __init__(self, mode = "time", data=None,
def __init__(self, mode="time", data=None,
trad=None, canvas=None, toolbar=None,
parent=None):
super(Plot, self).__init__(
canvas = canvas,
trad = trad,
data = data,
toolbar = toolbar,
parent = parent
canvas=canvas,
trad=trad,
data=data,
toolbar=toolbar,
parent=parent
)
self._table_headers = self._trad.get_dict("table_headers")
@@ -72,8 +73,8 @@ class Plot(PamhyrPlot):
map(
lambda v: str(
datetime.fromtimestamp(v[0]) - t0
).split(",")[0]\
.replace("days", _translate("BoundaryCondition", "days"))\
).split(",")[0]
.replace("days", _translate("BoundaryCondition", "days"))
.replace("day", _translate("BoundaryCondition", "day")),
fx
)
@@ -88,7 +89,6 @@ class Plot(PamhyrPlot):
self.canvas.axes.set_xticks(ticks=xx, labels=xt, rotation=45)
@timer
def draw(self):
self.canvas.axes.cla()
@@ -122,7 +122,7 @@ class Plot(PamhyrPlot):
self.canvas.axes.autoscale_view(True, True, True)
self.canvas.figure.tight_layout()
self.canvas.figure.canvas.draw_idle()
#self.toolbar.update()
# self.toolbar.update()
self._init = True
+1
View File
@@ -51,6 +51,7 @@ _translate = QCoreApplication.translate
logger = logging.getLogger()
class TableModel(PamhyrTableModel):
def data(self, index, role):
if role == Qt.TextAlignmentRole:
@@ -29,6 +29,7 @@ from Model.BoundaryCondition.BoundaryCondition import BoundaryCondition
logger = logging.getLogger()
class SetDataCommand(QUndoCommand):
def __init__(self, data, index, column, new_value):
QUndoCommand.__init__(self)
@@ -46,6 +47,7 @@ class SetDataCommand(QUndoCommand):
def redo(self):
self._data._set_i_c_v(self._index, self._column, self._new)
class SetMetaDataCommand(QUndoCommand):
def __init__(self, data, column, new_value):
QUndoCommand.__init__(self)
@@ -89,6 +91,7 @@ class AddCommand(QUndoCommand):
else:
self._data.insert(self._index, self._new)
class DelCommand(QUndoCommand):
def __init__(self, data, rows):
QUndoCommand.__init__(self)
@@ -108,6 +111,7 @@ class DelCommand(QUndoCommand):
def redo(self):
self._data.delete_i(self._rows)
class SortCommand(QUndoCommand):
def __init__(self, data, _reverse):
QUndoCommand.__init__(self)
+23 -22
View File
@@ -53,6 +53,7 @@ _translate = QCoreApplication.translate
logger = logging.getLogger()
class WD50Sigma(PamhyrWidget):
_pamhyr_ui = "d50sigma"
@@ -94,6 +95,7 @@ class WD50Sigma(PamhyrWidget):
def valueChangedSigma(self, value):
self.sigmaChanged.emit(value)
class EditBoundaryConditionWindow(PamhyrWindow):
_pamhyr_ui = "EditBoundaryConditions"
_pamhyr_name = "Edit Boundary Conditions"
@@ -115,11 +117,11 @@ class EditBoundaryConditionWindow(PamhyrWindow):
)
super(EditBoundaryConditionWindow, self).__init__(
title = name,
study = study,
config = config,
trad = trad,
parent = parent
title=name,
study=study,
config=config,
trad=trad,
parent=parent
)
self.setup_table()
@@ -132,7 +134,7 @@ class EditBoundaryConditionWindow(PamhyrWindow):
if self._is_solid:
layout = self.find(QVBoxLayout, "verticalLayout_table")
self._d50sigma = WD50Sigma(parent = self)
self._d50sigma = WD50Sigma(parent=self)
layout.addWidget(self._d50sigma)
self._d50sigma.set_d50(self._data.d50)
@@ -145,22 +147,22 @@ class EditBoundaryConditionWindow(PamhyrWindow):
headers[h] = table_headers[h]
self._delegate_time = PamhyrExTimeDelegate(
data = self._data,
mode = self._study.time_system,
parent = self
data=self._data,
mode=self._study.time_system,
parent=self
)
table = self.find(QTableView, "tableView")
self._table = TableModel(
table_view = table,
table_headers = headers,
editable_headers = self._data.header,
delegates = {
table_view=table,
table_headers=headers,
editable_headers=self._data.header,
delegates={
"time": self._delegate_time,
},
data = self._data,
undo = self._undo_stack,
opt_data = self._study.time_system
data=self._data,
undo=self._undo_stack,
opt_data=self._study.time_system
)
table.setModel(self._table)
@@ -178,11 +180,11 @@ class EditBoundaryConditionWindow(PamhyrWindow):
self.verticalLayout.addWidget(self.canvas)
self.plot = Plot(
canvas = self.canvas,
data = self._data,
mode = self._study.time_system,
trad = self._trad,
toolbar = self.toolbar,
canvas=self.canvas,
data=self._data,
mode=self._study.time_system,
trad=self._trad,
toolbar=self.toolbar,
)
self.plot.draw()
@@ -270,7 +272,6 @@ class EditBoundaryConditionWindow(PamhyrWindow):
self._table.move_down(row)
self.plot.update()
def _copy(self):
rows = self.index_selected_rows()
@@ -24,6 +24,7 @@ from View.BoundaryCondition.translate import BCTranslate
_translate = QCoreApplication.translate
class BCETranslate(BCTranslate):
def __init__(self):
super(BCETranslate, self).__init__()
+7 -5
View File
@@ -52,6 +52,7 @@ logger = logging.getLogger()
_translate = QCoreApplication.translate
class ComboBoxDelegate(QItemDelegate):
def __init__(self, data=None, mode="type", tab="", trad=None, parent=None):
super(ComboBoxDelegate, self).__init__(parent)
@@ -157,20 +158,21 @@ class TableModel(PamhyrTableModel):
if self._headers[column] == "name":
self._undo.push(
SetNameCommand(
self._lst, self._tab,row, value
self._lst, self._tab, row, value
)
)
elif self._headers[column] == "type":
key = next(k for k, v in self._long_types.items() if v == value)
key = next(k for k, v in self._long_types.items()
if v == value)
self._undo.push(
SetTypeCommand(
self._lst, self._tab,row, BC_types[key]
self._lst, self._tab, row, BC_types[key]
)
)
elif self._headers[column] == "node":
self._undo.push(
SetNodeCommand(
self._lst, self._tab,row, self._data.node(value)
self._lst, self._tab, row, self._data.node(value)
)
)
except Exception as e:
@@ -185,7 +187,7 @@ class TableModel(PamhyrTableModel):
self._undo.push(
AddCommand(
self._lst, self._tab,row
self._lst, self._tab, row
)
)
@@ -26,6 +26,7 @@ from PyQt5.QtWidgets import (
from Model.BoundaryCondition.BoundaryCondition import BoundaryCondition
from Model.BoundaryCondition.BoundaryConditionList import BoundaryConditionList
class SetNameCommand(QUndoCommand):
def __init__(self, bcs, tab, index, new_value):
QUndoCommand.__init__(self)
@@ -42,6 +43,7 @@ class SetNameCommand(QUndoCommand):
def redo(self):
self._bcs.get(self._tab, self._index).name = self._new
class SetNodeCommand(QUndoCommand):
def __init__(self, bcs, tab, index, node):
QUndoCommand.__init__(self)
@@ -58,6 +60,7 @@ class SetNodeCommand(QUndoCommand):
def redo(self):
self._bcs.get(self._tab, self._index).node = self._new
class SetTypeCommand(QUndoCommand):
def __init__(self, bcs, tab, index, _type):
QUndoCommand.__init__(self)
@@ -76,6 +79,7 @@ class SetTypeCommand(QUndoCommand):
def redo(self):
self._bcs.set(self._tab, self._index, self._new)
class AddCommand(QUndoCommand):
def __init__(self, bcs, tab, index):
QUndoCommand.__init__(self)
@@ -94,6 +98,7 @@ class AddCommand(QUndoCommand):
else:
self._bcs.insert(self._tab, self._index, self._new)
class DelCommand(QUndoCommand):
def __init__(self, bcs, tab, rows):
QUndoCommand.__init__(self)
@@ -114,6 +119,7 @@ class DelCommand(QUndoCommand):
def redo(self):
self._bcs.delete_i(self._tab, self._rows)
class SortCommand(QUndoCommand):
def __init__(self, bcs, tab, _reverse):
QUndoCommand.__init__(self)
+23 -22
View File
@@ -62,6 +62,7 @@ _translate = QCoreApplication.translate
logger = logging.getLogger()
class BoundaryConditionWindow(PamhyrWindow):
_pamhyr_ui = "BoundaryConditions"
_pamhyr_name = "Boundary conditions"
@@ -70,10 +71,10 @@ class BoundaryConditionWindow(PamhyrWindow):
name = self._pamhyr_name + " - " + study.name
super(BoundaryConditionWindow, self).__init__(
title = name,
study = study,
config = config,
trad = BCTranslate(),
title=name,
study=study,
config=config,
trad=BCTranslate(),
parent=parent
)
@@ -90,33 +91,33 @@ class BoundaryConditionWindow(PamhyrWindow):
for t in ["liquid", "solid", "suspenssion"]:
self._delegate_type = ComboBoxDelegate(
trad = self._trad,
data = self._study.river,
mode = "type",
tab = t,
trad=self._trad,
data=self._study.river,
mode="type",
tab=t,
parent=self
)
self._delegate_node = ComboBoxDelegate(
trad = self._trad,
data = self._study.river,
mode = "node",
tab = t,
trad=self._trad,
data=self._study.river,
mode="node",
tab=t,
parent=self
)
table = self.find(QTableView, f"tableView_{t}")
self._table[t] = TableModel(
table_view = table,
table_headers = self._trad.get_dict("table_headers"),
editable_headers = ["name", "type", "node"],
delegates = {
table_view=table,
table_headers=self._trad.get_dict("table_headers"),
editable_headers=["name", "type", "node"],
delegates={
"type": self._delegate_type,
"node": self._delegate_node,
},
trad = self._trad,
data = self._study.river,
undo = self._undo_stack,
opt_data = t,
trad=self._trad,
data=self._study.river,
undo=self._undo_stack,
opt_data=t,
)
table.setModel(self._table[t])
table.setSelectionBehavior(QAbstractItemView.SelectRows)
@@ -126,7 +127,7 @@ class BoundaryConditionWindow(PamhyrWindow):
def setup_graph(self):
self.graph_widget = GraphWidget(
self._study.river,
min_size=None, size=(200,200),
min_size=None, size=(200, 200),
only_display=True,
parent=self
)
@@ -215,7 +216,7 @@ class BoundaryConditionWindow(PamhyrWindow):
for row in rows:
win = self.sub_win_filter_first(
"Edit boundary condition",
contain = [f"({self._bcs.get(tab, row).id})"]
contain=[f"({self._bcs.get(tab, row).id})"]
)
if win is None:
+1
View File
@@ -37,6 +37,7 @@ BC_types = {
"SL": Solid,
}
class BCTranslate(PamhyrTranslate):
def __init__(self):
super(BCTranslate, self).__init__()