mirror of
https://github.com/enzet/map-machine.git
synced 2025-06-08 22:01:51 +02:00
Fix code style.
This commit is contained in:
parent
c9fe5e55b6
commit
2667ee9d02
16 changed files with 228 additions and 240 deletions
|
@ -1,25 +1,34 @@
|
|||
"""
|
||||
Röntgen utility file.
|
||||
|
||||
Author: Sergey Vartanov (me@enzet.ru).
|
||||
"""
|
||||
from dataclasses import dataclass
|
||||
from typing import Any
|
||||
|
||||
|
||||
@dataclass
|
||||
class MinMax:
|
||||
"""
|
||||
Minimum and maximum.
|
||||
"""
|
||||
def __init__(self, min_=None, max_=None):
|
||||
self.min_ = min_
|
||||
self.max_ = max_
|
||||
min_: Any = None
|
||||
max_: Any = None
|
||||
|
||||
def update(self, value):
|
||||
def update(self, value: Any) -> None:
|
||||
"""
|
||||
Update minimum and maximum with new value.
|
||||
"""
|
||||
self.min_ = value if not self.min_ or value < self.min_ else self.min_
|
||||
self.max_ = value if not self.max_ or value > self.max_ else self.max_
|
||||
|
||||
def delta(self):
|
||||
def delta(self) -> Any:
|
||||
"""
|
||||
Difference between maximum and minimum.
|
||||
"""
|
||||
return self.max_ - self.min_
|
||||
|
||||
def center(self):
|
||||
def center(self) -> Any:
|
||||
"""
|
||||
Get middle point between minimum and maximum.
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue