mirror of https://gitlab.com/pamhyr/pamhyr2
Frictions: Fix plot drawing crash.
parent
b12e935a5d
commit
e400980103
|
|
@ -129,6 +129,15 @@ class Friction(SQLSubModel):
|
||||||
def has_edge(self):
|
def has_edge(self):
|
||||||
return self._edge is not None
|
return self._edge is not None
|
||||||
|
|
||||||
|
def has_coefficient(self):
|
||||||
|
return (
|
||||||
|
self._begin_strickler is not None and
|
||||||
|
self._end_strickler is not None
|
||||||
|
)
|
||||||
|
|
||||||
|
def is_full_defined(self):
|
||||||
|
return self.has_edge() and self.has_coefficient()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def begin_kp(self):
|
def begin_kp(self):
|
||||||
return self._begin_kp
|
return self._begin_kp
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
from tools import timer, flatten
|
from tools import timer, flatten
|
||||||
from View.Tools.PamhyrPlot import PamhyrPlot
|
from View.Tools.PamhyrPlot import PamhyrPlot
|
||||||
|
|
||||||
|
|
@ -23,13 +25,20 @@ from PyQt5.QtCore import (
|
||||||
QCoreApplication
|
QCoreApplication
|
||||||
)
|
)
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
_translate = QCoreApplication.translate
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
|
|
||||||
class PlotStricklers(PamhyrPlot):
|
class PlotStricklers(PamhyrPlot):
|
||||||
def draw_frictions(self, frictions, color="r"):
|
def draw_frictions(self, frictions, color="r"):
|
||||||
lst = frictions
|
lst = sorted(
|
||||||
lst.sort(key=lambda s: s.begin_kp)
|
filter(
|
||||||
|
lambda f: f.is_full_defined(),
|
||||||
|
frictions
|
||||||
|
),
|
||||||
|
key=lambda s: s.begin_kp
|
||||||
|
)
|
||||||
|
|
||||||
coef = flatten(
|
coef = flatten(
|
||||||
map(
|
map(
|
||||||
|
|
|
||||||
|
|
@ -199,10 +199,7 @@ def flatten(lst):
|
||||||
Returns:
|
Returns:
|
||||||
returns a list of element
|
returns a list of element
|
||||||
"""
|
"""
|
||||||
if not lst:
|
return reduce(list.__add__, lst, [])
|
||||||
return []
|
|
||||||
|
|
||||||
return reduce(list.__add__, lst)
|
|
||||||
|
|
||||||
|
|
||||||
def timestamp(dt: datetime):
|
def timestamp(dt: datetime):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue