From 1d97827d00bcd6cf5be1eea31ed6189b76eb389f Mon Sep 17 00:00:00 2001 From: Keurfon Luu Date: Sun, 19 May 2024 10:27:18 +0200 Subject: [PATCH] more codacy --- toughio/_io/output/_common.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/toughio/_io/output/_common.py b/toughio/_io/output/_common.py index 07cae11f..0a7400a9 100644 --- a/toughio/_io/output/_common.py +++ b/toughio/_io/output/_common.py @@ -21,12 +21,12 @@ def __init__(self, time, data, labels=None): self._labels = list(labels) if labels is not None else labels @abstractmethod - def __getitem__(self, slice): + def __getitem__(self, islice): """Slice output.""" raise NotImplementedError() @abstractmethod - def index(self, *args): + def index(self, label, *args): """Get index of element or connection.""" if self.labels is None: raise AttributeError() @@ -208,16 +208,16 @@ def __getitem__(self, islice): [self._labels[i] for i in islice], ) - def index(self, label1, label2): + def index(self, label, label2=None): """ Get index of connection. Parameters ---------- - label1 : str - Label of first element of connection. - label2 : str - Label of second element of connection. + label : str + Label of connection or label of first element of connection. + label2 : str or None, optional, default None + Label of second element of connection (if `label` is the label of the first element). Returns ------- @@ -228,7 +228,10 @@ def index(self, label1, label2): super().index() labels = ["".join(label) for label in self.labels] - return labels.index(f"{label1}{label2}") + if label2 is not None: + label = f"{label}{label2}" + + return labels.index(label) def to_output(file_type, labels_order, headers, times, labels, data):