mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
pep8: Some modifications to respect pep8 standard code.
This commit is contained in:
1 parent
8544dd1144
commit
fa2454d079
152 files changed
+1626
-1277
No files matched your search
@@ -18,8 +18,9 @@
|
||||
|
||||
from Model.Except import NotImplementedMethodeError
|
||||
|
||||
|
||||
class Point(object):
|
||||
def __init__(self, name:str = "", profile=None, status = None):
|
||||
def __init__(self, name: str = "", profile=None, status=None):
|
||||
super(Point, self).__init__()
|
||||
|
||||
self._status = status
|
||||
@@ -28,7 +29,6 @@ class Point(object):
|
||||
self._profile = profile
|
||||
self._sl = None
|
||||
|
||||
|
||||
@property
|
||||
def sl(self):
|
||||
if self._sl is None:
|
||||
|
||||
@@ -20,10 +20,11 @@ from math import dist
|
||||
|
||||
from Model.Geometry.Point import Point
|
||||
|
||||
|
||||
class PointAC(Point):
|
||||
def __init__(self, a:float = 0.0, c:float = 0.0,
|
||||
name: str = "", status = None):
|
||||
super(PointXY, self).__init__(name = name, status = status)
|
||||
def __init__(self, a: float = 0.0, c: float = 0.0,
|
||||
name: str = "", status=None):
|
||||
super(PointXY, self).__init__(name=name, status=status)
|
||||
|
||||
self._a = float(a)
|
||||
self._c = float(c)
|
||||
|
||||
@@ -22,12 +22,14 @@ import numpy as np
|
||||
from Model.Tools.PamhyrDB import SQLSubModel
|
||||
from Model.Geometry.Point import Point
|
||||
|
||||
|
||||
class PointXYZ(Point, SQLSubModel):
|
||||
_sub_classes = []
|
||||
|
||||
def __init__(self, x:float = 0.0, y:float = 0.0, z:float = 0.0,
|
||||
name:str = "", profile = None, status = None):
|
||||
super(PointXYZ, self).__init__(name=name, profile=profile, status=status)
|
||||
def __init__(self, x: float = 0.0, y: float = 0.0, z: float = 0.0,
|
||||
name: str = "", profile=None, status=None):
|
||||
super(PointXYZ, self).__init__(
|
||||
name=name, profile=profile, status=status)
|
||||
|
||||
self._x = float(x)
|
||||
self._y = float(y)
|
||||
@@ -69,7 +71,7 @@ class PointXYZ(Point, SQLSubModel):
|
||||
return True
|
||||
|
||||
@classmethod
|
||||
def _sql_load(cls, execute, data = None):
|
||||
def _sql_load(cls, execute, data=None):
|
||||
status = data["status"]
|
||||
profile = data["profile"]
|
||||
|
||||
@@ -89,10 +91,10 @@ class PointXYZ(Point, SQLSubModel):
|
||||
sl = row[5]
|
||||
|
||||
new = cls(
|
||||
name = name,
|
||||
x = x, y = y, z = z,
|
||||
profile = profile,
|
||||
status = status
|
||||
name=name,
|
||||
x=x, y=y, z=z,
|
||||
profile=profile,
|
||||
status=status
|
||||
)
|
||||
|
||||
if sl == -1 or sl == None:
|
||||
@@ -107,7 +109,7 @@ class PointXYZ(Point, SQLSubModel):
|
||||
|
||||
yield ind, new
|
||||
|
||||
def _sql_save(self, execute, data = None):
|
||||
def _sql_save(self, execute, data=None):
|
||||
profile = data["profile"]
|
||||
ind = data["ind"]
|
||||
|
||||
@@ -115,7 +117,7 @@ class PointXYZ(Point, SQLSubModel):
|
||||
|
||||
sql = (
|
||||
"INSERT OR REPLACE INTO " +
|
||||
"geometry_pointXYZ(ind, name, x, y, z, profile, sl) "+
|
||||
"geometry_pointXYZ(ind, name, x, y, z, profile, sl) " +
|
||||
"VALUES (" +
|
||||
f"{ind}, '{self._sql_format(self._name)}', " +
|
||||
f"{self.x}, {self.y}, {self.z}, " +
|
||||
@@ -126,7 +128,6 @@ class PointXYZ(Point, SQLSubModel):
|
||||
|
||||
return True
|
||||
|
||||
|
||||
@classmethod
|
||||
def from_data(cls, header, data):
|
||||
point = None
|
||||
@@ -149,7 +150,6 @@ class PointXYZ(Point, SQLSubModel):
|
||||
|
||||
return point
|
||||
|
||||
|
||||
def __repr__(self):
|
||||
return f"({self._x}, {self._y}, {self._z}, {self._name})"
|
||||
|
||||
|
||||
@@ -25,14 +25,15 @@ from Model.Except import NotImplementedMethodeError
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class Profile(object):
|
||||
_id_cnt = 0
|
||||
|
||||
def __init__(self, id:int = -1, num:int = 0,
|
||||
kp:float = 0.0, name:str = "",
|
||||
code1:int = 0, code2:int = 0,
|
||||
_type:str = "", reach = None,
|
||||
status = None):
|
||||
def __init__(self, id: int = -1, num: int = 0,
|
||||
kp: float = 0.0, name: str = "",
|
||||
code1: int = 0, code2: int = 0,
|
||||
_type: str = "", reach=None,
|
||||
status=None):
|
||||
super(Profile, self).__init__()
|
||||
|
||||
self._status = status
|
||||
@@ -71,7 +72,7 @@ class Profile(object):
|
||||
lambda p: p[1],
|
||||
sorted(
|
||||
self._points,
|
||||
key = lambda p: p[0]
|
||||
key=lambda p: p[0]
|
||||
)
|
||||
)
|
||||
)
|
||||
@@ -185,7 +186,7 @@ class Profile(object):
|
||||
self._profile_type = value
|
||||
self._status.modified()
|
||||
|
||||
def point(self, i:int):
|
||||
def point(self, i: int):
|
||||
if i < len(self.points):
|
||||
return self.points[i]
|
||||
|
||||
@@ -200,8 +201,7 @@ class Profile(object):
|
||||
return [point for point in self.points
|
||||
if point.point_is_named()]
|
||||
|
||||
|
||||
def insert_point(self, index: int, point:Point):
|
||||
def insert_point(self, index: int, point: Point):
|
||||
"""Insert point at index.
|
||||
|
||||
Args:
|
||||
@@ -214,7 +214,6 @@ class Profile(object):
|
||||
self.points.insert(index, point)
|
||||
self._status.modified()
|
||||
|
||||
|
||||
def delete(self, indexes: int):
|
||||
"""Delete points at index
|
||||
|
||||
@@ -281,11 +280,11 @@ class Profile(object):
|
||||
|
||||
@timer
|
||||
def sort(self, column, is_reversed: bool = False):
|
||||
predicate = lambda p: p.x
|
||||
def predicate(p): return p.x
|
||||
if column == 'y':
|
||||
predicate = lambda p: p.y
|
||||
def predicate(p): return p.y
|
||||
elif column == 'z':
|
||||
predicate = lambda p: p.z
|
||||
def predicate(p): return p.z
|
||||
|
||||
self.points = sorted(
|
||||
self.points,
|
||||
|
||||
@@ -30,6 +30,7 @@ from Model.Geometry.Vector_1d import Vector1d
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class ProfileXYZ(Profile, SQLSubModel):
|
||||
_sub_classes = [
|
||||
PointXYZ,
|
||||
@@ -39,11 +40,11 @@ class ProfileXYZ(Profile, SQLSubModel):
|
||||
id: int = -1,
|
||||
name: str = "",
|
||||
kp: float = 0.,
|
||||
reach = None,
|
||||
num = 0,
|
||||
reach=None,
|
||||
num=0,
|
||||
nb_point: int = 0,
|
||||
code1: int = 0, code2: int = 0,
|
||||
status = None):
|
||||
status=None):
|
||||
"""ProfileXYZ constructor
|
||||
|
||||
Args:
|
||||
@@ -57,14 +58,14 @@ class ProfileXYZ(Profile, SQLSubModel):
|
||||
Nothing.
|
||||
"""
|
||||
super(ProfileXYZ, self).__init__(
|
||||
id = id,
|
||||
num = num,
|
||||
name = name,
|
||||
kp = kp,
|
||||
code1 = code1, code2 = code2,
|
||||
_type = "XYZ",
|
||||
reach = reach,
|
||||
status = status,
|
||||
id=id,
|
||||
num=num,
|
||||
name=name,
|
||||
kp=kp,
|
||||
code1=code1, code2=code2,
|
||||
_type="XYZ",
|
||||
reach=reach,
|
||||
status=status,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
@@ -103,7 +104,7 @@ class ProfileXYZ(Profile, SQLSubModel):
|
||||
return cls._update_submodel(execute, version)
|
||||
|
||||
@classmethod
|
||||
def _sql_load(cls, execute, data = None):
|
||||
def _sql_load(cls, execute, data=None):
|
||||
profiles = []
|
||||
status = data["status"]
|
||||
reach = data["reach"]
|
||||
@@ -128,11 +129,11 @@ class ProfileXYZ(Profile, SQLSubModel):
|
||||
sl = row[7]
|
||||
|
||||
new = cls(
|
||||
id=id, num = num,
|
||||
name = name, kp = kp,
|
||||
code1 = code1, code2 = code2,
|
||||
reach = data["parent"],
|
||||
status = status
|
||||
id=id, num=num,
|
||||
name=name, kp=kp,
|
||||
code1=code1, code2=code2,
|
||||
reach=data["parent"],
|
||||
status=status
|
||||
)
|
||||
|
||||
if sl == -1 or sl == None:
|
||||
@@ -154,7 +155,7 @@ class ProfileXYZ(Profile, SQLSubModel):
|
||||
|
||||
# return profiles
|
||||
|
||||
def _sql_save(self, execute, data = None):
|
||||
def _sql_save(self, execute, data=None):
|
||||
ok = True
|
||||
ind = data["ind"]
|
||||
|
||||
@@ -162,7 +163,7 @@ class ProfileXYZ(Profile, SQLSubModel):
|
||||
|
||||
sql = (
|
||||
"INSERT OR REPLACE INTO " +
|
||||
"geometry_profileXYZ(id, ind, name, reach, kp, num, code1, code2, sl) "+
|
||||
"geometry_profileXYZ(id, ind, name, reach, kp, num, code1, code2, sl) " +
|
||||
"VALUES (" +
|
||||
f"{self.id}, {ind}, '{self._sql_format(self._name)}', " +
|
||||
f"{self.reach.id}, {self.kp}, {self.num}, " +
|
||||
@@ -225,7 +226,6 @@ class ProfileXYZ(Profile, SQLSubModel):
|
||||
|
||||
return point
|
||||
|
||||
|
||||
def x(self):
|
||||
return [point.x for point in self.points]
|
||||
|
||||
@@ -374,9 +374,9 @@ class ProfileXYZ(Profile, SQLSubModel):
|
||||
constant = 0.0
|
||||
|
||||
if (first_named_point is not None and
|
||||
last_named_point is not None):
|
||||
last_named_point is not None):
|
||||
if (first_named_point != last_named_point and
|
||||
first_named_point.x != last_named_point.x):
|
||||
first_named_point.x != last_named_point.x):
|
||||
vector = Vector1d(first_named_point, last_named_point)
|
||||
normalized_direction_vec = vector.normalized_direction_vector()
|
||||
else:
|
||||
|
||||
@@ -36,6 +36,7 @@ from Model.Except import FileFormatError, exception_message_box
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class Reach(SQLSubModel):
|
||||
_sub_classes = [
|
||||
ProfileXYZ,
|
||||
@@ -59,17 +60,17 @@ class Reach(SQLSubModel):
|
||||
return cls._update_submodel(execute, version)
|
||||
|
||||
@classmethod
|
||||
def _sql_load(cls, execute, data = None):
|
||||
new = cls(status = data["status"], parent = data["parent"])
|
||||
def _sql_load(cls, execute, data=None):
|
||||
new = cls(status=data["status"], parent=data["parent"])
|
||||
|
||||
new._profiles = ProfileXYZ._sql_load(
|
||||
execute,
|
||||
data = data
|
||||
data=data
|
||||
)
|
||||
|
||||
return new
|
||||
|
||||
def _sql_save(self, execute, data = None):
|
||||
def _sql_save(self, execute, data=None):
|
||||
# Delete old data
|
||||
execute(f"DELETE FROM geometry_profileXYZ WHERE reach = {self.id}")
|
||||
# execute(f"DELETE FROM geometry_pointXYZ")
|
||||
@@ -115,7 +116,7 @@ class Reach(SQLSubModel):
|
||||
lambda p: p[1],
|
||||
sorted(
|
||||
self._profiles,
|
||||
key = lambda p: p[0]
|
||||
key=lambda p: p[0]
|
||||
)
|
||||
)
|
||||
)
|
||||
@@ -195,7 +196,6 @@ class Reach(SQLSubModel):
|
||||
self._update_profile_numbers()
|
||||
self._status.modified()
|
||||
|
||||
|
||||
def delete(self, indexes):
|
||||
"""Delete some elements in profile list
|
||||
|
||||
@@ -242,7 +242,6 @@ class Reach(SQLSubModel):
|
||||
self._update_profile_numbers()
|
||||
self._status.modified()
|
||||
|
||||
|
||||
def move_up_profile(self, index: int):
|
||||
if index < len(self.profiles):
|
||||
next = index - 1
|
||||
@@ -298,7 +297,6 @@ class Reach(SQLSubModel):
|
||||
def get_kp_max(self):
|
||||
return max(self.get_kp())
|
||||
|
||||
|
||||
# Sediment Layers
|
||||
|
||||
def get_sl(self):
|
||||
@@ -437,7 +435,6 @@ class Reach(SQLSubModel):
|
||||
def get_guidelines_z(self):
|
||||
return self._map_guidelines_points(lambda p: p.z)
|
||||
|
||||
|
||||
# Sort
|
||||
|
||||
@timer
|
||||
@@ -482,7 +479,8 @@ class Reach(SQLSubModel):
|
||||
|
||||
try:
|
||||
list_profile, list_header = self.read_file_st(str(file_path_name))
|
||||
profile_header = ["num", "code1", "code2", "nb_point", "kp", "name"]
|
||||
profile_header = ["num", "code1",
|
||||
"code2", "nb_point", "kp", "name"]
|
||||
|
||||
if list_profile and list_header:
|
||||
for ind, profile in enumerate(list_profile):
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
import numpy as np
|
||||
from Model.Geometry.PointXYZ import PointXYZ
|
||||
|
||||
|
||||
class Vector1d:
|
||||
def __init__(self, a: PointXYZ, b: PointXYZ):
|
||||
self.A = a
|
||||
|
||||
Reference in new issue
Block a user