Skip to content

Commit 9d73268

Browse files
committed
Moved length validation to a static method.
1 parent 6c8213b commit 9d73268

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

rtanalysis/rtanalysis.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@ def fit(self, rt, accuracy, verbose=True):
4343
rt = self._ensure_series_type(rt)
4444
accuracy = self._ensure_series_type(accuracy)
4545

46-
try:
47-
assert rt.shape[0] == accuracy.shape[0]
48-
except AssertionError as e:
49-
raise ValueError("rt and accuracy must be the same length!") from e
46+
self._validate_length(rt, accuracy)
5047

5148
# ensure that accuracy values are boolean
5249
assert not set(accuracy.unique()).difference([True, False])
@@ -69,6 +66,15 @@ def fit(self, rt, accuracy, verbose=True):
6966
if verbose:
7067
print(f"mean RT: {self.mean_rt_}")
7168
print(f"mean accuracy: {self.mean_accuracy_}")
69+
70+
@staticmethod
71+
def _validate_length(rt, accuracy):
72+
same_length = rt.shape[0] == accuracy.shape[0]
73+
try:
74+
assert same_length
75+
except AssertionError as e:
76+
raise ValueError("RT and accuracy must be the same length!") from e
77+
7278

7379
@staticmethod
7480
def _ensure_series_type(var):

0 commit comments

Comments
 (0)