Skip to content

Commit

Permalink
more codacy
Browse files Browse the repository at this point in the history
  • Loading branch information
keurfonluu committed May 19, 2024
1 parent a31ad2a commit 1d97827
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions toughio/_io/output/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Check warning on line 26 in toughio/_io/output/_common.py

View check run for this annotation

Codecov / codecov/patch

toughio/_io/output/_common.py#L26

Added line #L26 was not covered by tests

@abstractmethod
def index(self, *args):
def index(self, label, *args):
"""Get index of element or connection."""
if self.labels is None:
raise AttributeError()

Check warning on line 32 in toughio/_io/output/_common.py

View check run for this annotation

Codecov / codecov/patch

toughio/_io/output/_common.py#L31-L32

Added lines #L31 - L32 were not covered by tests
Expand Down Expand Up @@ -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
-------
Expand All @@ -228,7 +228,10 @@ def index(self, label1, label2):
super().index()
labels = ["".join(label) for label in self.labels]

Check warning on line 229 in toughio/_io/output/_common.py

View check run for this annotation

Codecov / codecov/patch

toughio/_io/output/_common.py#L228-L229

Added lines #L228 - L229 were not covered by tests

return labels.index(f"{label1}{label2}")
if label2 is not None:
label = f"{label}{label2}"

Check warning on line 232 in toughio/_io/output/_common.py

View check run for this annotation

Codecov / codecov/patch

toughio/_io/output/_common.py#L231-L232

Added lines #L231 - L232 were not covered by tests

return labels.index(label)

Check warning on line 234 in toughio/_io/output/_common.py

View check run for this annotation

Codecov / codecov/patch

toughio/_io/output/_common.py#L234

Added line #L234 was not covered by tests


def to_output(file_type, labels_order, headers, times, labels, data):
Expand Down

0 comments on commit 1d97827

Please sign in to comment.