Skip to content

Commit c44621a

Browse files
committed
BF: recreates previous option of using trials.next() to advance trials
This had been lost in python futurize step in GH-38740bcaff28d063f6519461d2780a3850886889 Closes GH-2322
1 parent b042258 commit c44621a

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

psychopy/data/staircase.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,8 @@ def __next__(self):
393393
else:
394394
self._terminate()
395395

396+
next = __next__ # allows user to call without a loop `val = trials.next()`
397+
396398
def _intensityInc(self):
397399
"""increment the current intensity and reset counter
398400
"""
@@ -1035,6 +1037,8 @@ def __next__(self):
10351037
else:
10361038
self._terminate()
10371039

1040+
next = __next__ # allows user to call without a loop `val = trials.next()`
1041+
10381042
def _checkFinished(self):
10391043
"""checks if we are finished
10401044
Updates attribute: `finished`
@@ -1242,6 +1246,8 @@ def __next__(self):
12421246
else:
12431247
self._terminate()
12441248

1249+
next = __next__ # allows user to call without a loop `val = trials.next()`
1250+
12451251
def _checkFinished(self):
12461252
"""checks if we are finished
12471253
Updates attribute: `finished`
@@ -1513,6 +1519,8 @@ def __next__(self):
15131519
else:
15141520
raise StopIteration
15151521

1522+
next = __next__ # allows user to call without a loop `val = trials.next()`
1523+
15161524
def _startNewPass(self):
15171525
"""Create a new iteration of the running staircases for this pass.
15181526

psychopy/data/trial.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,8 @@ def __next__(self):
362362
logging.exp(msg % vals, obj=self.thisTrial)
363363
return self.thisTrial
364364

365+
next = __next__ # allows user to call without a loop `val = trials.next()`
366+
365367
def getFutureTrial(self, n=1):
366368
"""Returns the condition for n trials into the future,
367369
without advancing the trials. A negative n returns a previous (past)
@@ -1020,6 +1022,8 @@ def __next__(self):
10201022
logging.exp(msg % vals, obj=self.thisTrial)
10211023
return self.thisTrial
10221024

1025+
next = __next__ # allows user to call without a loop `val = trials.next()`
1026+
10231027
def getFutureTrial(self, n=1):
10241028
"""Returns the condition for n trials into the future, without
10251029
advancing the trials. Returns 'None' if attempting to go beyond
@@ -1516,6 +1520,8 @@ def __next__(self):
15161520
logging.exp(msg % vals, obj=self.thisTrial)
15171521
return self.thisTrial
15181522

1523+
next = __next__ # allows user to call without a loop `val = trials.next()`
1524+
15191525
def getCurrentTrialPosInDataHandler(self):
15201526
# if there's no trial weights, then the current position is simply
15211527
# [trialIndex, nRepetition]

0 commit comments

Comments
 (0)