Skip to content

Commit

Permalink
fix lint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
JakaKokosar committed Dec 8, 2023
1 parent 9f04d05 commit b973ad0
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions orangecontrib/survival_analysis/widgets/data.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from functools import wraps
from typing import Tuple, Optional
from typing import Optional

from Orange.widgets.utils.messages import UnboundMsg
from Orange.data import Table, Domain, Variable
Expand Down Expand Up @@ -30,7 +30,7 @@ def contains_survival_endpoints(domain: Domain):

def get_survival_endpoints(
domain: Domain,
) -> Tuple[Optional[Variable], Optional[Variable]]:
) -> tuple[Optional[Variable], Optional[Variable]]:
time_var = None
event_var = None
if domain is not None and contains_survival_endpoints(domain):
Expand Down
4 changes: 2 additions & 2 deletions orangecontrib/survival_analysis/widgets/owchorts.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
from functools import partial
from typing import Optional, Any, Tuple
from typing import Optional, Any
from enum import IntEnum

from lifelines.statistics import multivariate_logrank_test
Expand Down Expand Up @@ -169,7 +169,7 @@ def commit(

def stratify_data(
self, data: Table, state: TaskState
) -> Optional[Tuple[Table, CoxRegressionModel]]:
) -> Optional[tuple[Table, CoxRegressionModel]]:
steps = iter(np.linspace(0, 100, len(data)))

def callback():
Expand Down
16 changes: 8 additions & 8 deletions orangecontrib/survival_analysis/widgets/owkaplanmeier.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import numpy as np
import pyqtgraph as pg

from typing import Dict, List, Optional, NamedTuple
from typing import Optional, NamedTuple
from itertools import zip_longest

from AnyQt.QtGui import QBrush, QColor, QPainterPath, QPalette
Expand Down Expand Up @@ -72,7 +72,7 @@ def __init__(self, time, events, label=None, color=None):
)

self._label: str = label
self.color: List[int] = color
self.color: list[int] = color

# refactor this
time, survival = self._kmf.survival_function_.reset_index().values.T.tolist()
Expand Down Expand Up @@ -155,8 +155,8 @@ def set_highlighted(self, highlighted):


class SelectionInterval(NamedTuple):
x: List[int]
y: List[int]
x: list[int]
y: list[int]


class KaplanMeierViewBox(ViewBox):
Expand Down Expand Up @@ -277,16 +277,16 @@ class KaplanMeierPlot(gui.OWComponent, pg.PlotWidget):
HIGHLIGHT_RADIUS = 20 # in pixels
selection_changed = Signal()

selection: Dict[int, Optional[SelectionInterval]] = ContextSetting({})
selection: dict[int, Optional[SelectionInterval]] = ContextSetting({})

def __init__(self, parent: OWWidget = None):
gui.OWComponent.__init__(self, widget=parent)
pg.PlotWidget.__init__(self, parent=parent, viewBox=KaplanMeierViewBox(self))

self.parent: OWWidget = parent
self.highlighted_curve: Optional[int] = None
self.curves: Dict[int, EstimatedFunctionCurve] = {}
self.__selection_items: Dict[int, Optional[pg.PlotDataItem]] = {}
self.curves: dict[int, EstimatedFunctionCurve] = {}
self.__selection_items: dict[int, Optional[pg.PlotDataItem]] = {}

self.view_box: KaplanMeierViewBox = self.getViewBox()

Expand Down Expand Up @@ -645,7 +645,7 @@ def _get_discrete_var_color(self, index: Optional[int]):
if self.group_var is not None and index is not None:
return list(self.group_var.colors[index])

def generate_plot_curves(self) -> List[EstimatedFunctionCurve]:
def generate_plot_curves(self) -> list[EstimatedFunctionCurve]:
if self.time_var is None or self.event_var is None:
return []

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import itertools
import numpy as np
import pyqtgraph as pg
from typing import Dict, List, Optional, NamedTuple, Any
from typing import Optional, NamedTuple, Any

from AnyQt.QtGui import QColor
from AnyQt.QtCore import Qt, QPointF, pyqtSignal as Signal
Expand Down Expand Up @@ -59,7 +59,7 @@ def __init__(self, parent: OWWidget = None):
self.view_box = self.getViewBox()
self.plotItem.setMouseEnabled(x=False, y=False)

self.map_x_to_y: Optional[Dict[str, str]] = None
self.map_x_to_y: Optional[dict[str, str]] = None
self.plot_line: Optional[pg.PlotDataItem] = None
self.horizontal_line = CustomInfiniteLine(self, movable=True)
self.horizontal_line.setPen(
Expand Down Expand Up @@ -149,7 +149,7 @@ def __init__(self):

self.learner: Optional[CoxRegressionLearner] = CoxRegressionLearner()
self.data: Optional[Table] = None
self.trace: Optional[List[Result]] = None
self.trace: Optional[list[Result]] = None
gui.rubber(self.controlArea)

self.graph: StepwiseCoxRegressionPlot = StepwiseCoxRegressionPlot(parent=self)
Expand Down
4 changes: 2 additions & 2 deletions orangecontrib/survival_analysis/widgets/owsurvivalnomogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from collections import OrderedDict
from enum import IntEnum
from functools import singledispatch
from typing import List

import time
import numpy as np

Expand Down Expand Up @@ -79,7 +79,7 @@ def _(var: DiscreteVariable, *_):


@_get_labels.register(ContinuousVariable)
def _(_: ContinuousVariable, data_extremes: List, values: np.ndarray, *__):
def _(_: ContinuousVariable, data_extremes: list, values: np.ndarray, *__):
diff_ = np.nan_to_num(values[-1] - values[0])
k = (data_extremes[1] - data_extremes[0]) / diff_ if diff_ else 0
return [str(np.round(v * k + data_extremes[0], 1)) for v in values]
Expand Down

0 comments on commit b973ad0

Please sign in to comment.