Move cmp() to SeriesIntersection
This commit is contained in:
parent
c1f85adeec
commit
5b33653dcf
3 changed files with 11 additions and 12 deletions
|
@ -1,7 +1,6 @@
|
|||
import enum
|
||||
from typing import Self
|
||||
|
||||
from xmet.util import cmp
|
||||
from xmet.list import nearest
|
||||
|
||||
class SeriesIntersection(enum.Enum):
|
||||
|
@ -9,6 +8,15 @@ class SeriesIntersection(enum.Enum):
|
|||
EQUAL = 0
|
||||
LESSER = 1
|
||||
|
||||
@staticmethod
|
||||
def cmp(a, b) -> Self:
|
||||
if a > b:
|
||||
return SeriesIntersection.GREATER
|
||||
elif a == b:
|
||||
return SeriesIntersection.EQUAL
|
||||
elif a < b:
|
||||
return SeriesIntersection.LESSER
|
||||
|
||||
class Series(dict):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
@ -24,7 +32,7 @@ class Series(dict):
|
|||
if pair[0] > start:
|
||||
continue
|
||||
|
||||
sign = cmp(v1, v2)
|
||||
sign = SeriesIntersection.cmp(v1, v2)
|
||||
|
||||
if sign == intersection.value:
|
||||
if sign is intersection:
|
||||
return v1, pair[0]
|
||||
|
|
|
@ -5,7 +5,6 @@ from typing import Callable
|
|||
from itertools import product
|
||||
|
||||
from xmet.list import nearest
|
||||
from xmet.util import cmp
|
||||
from xmet.sounding import Sounding, SoundingSample
|
||||
from xmet.thermo import pressure_height, loft_parcel, moist_lapse_rate, \
|
||||
LAPSE_RATE_DRY, PRESSURE_MAX, PRESSURE_MIN, \
|
||||
|
|
|
@ -29,11 +29,3 @@ def each_chunk(fh: io.TextIOBase, sep: str, strip=None):
|
|||
|
||||
if ret != '':
|
||||
yield ret
|
||||
|
||||
def cmp(a, b):
|
||||
if a == b:
|
||||
return 0
|
||||
elif a > b:
|
||||
return -1
|
||||
elif a < b:
|
||||
return 1
|
||||
|
|
Loading…
Add table
Reference in a new issue