Skip to content

Commit

Permalink
BF: recreates previous option of using trials.next() to advance trials
Browse files Browse the repository at this point in the history
This had been lost in python futurize step in
GH-38740bcaff28d063f6519461d2780a3850886889

Closes GH-2322
  • Loading branch information
peircej committed Mar 5, 2019
1 parent b042258 commit c44621a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions psychopy/data/staircase.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,8 @@ def __next__(self):
else:
self._terminate()

next = __next__ # allows user to call without a loop `val = trials.next()`

def _intensityInc(self):
"""increment the current intensity and reset counter
"""
Expand Down Expand Up @@ -1035,6 +1037,8 @@ def __next__(self):
else:
self._terminate()

next = __next__ # allows user to call without a loop `val = trials.next()`

def _checkFinished(self):
"""checks if we are finished
Updates attribute: `finished`
Expand Down Expand Up @@ -1242,6 +1246,8 @@ def __next__(self):
else:
self._terminate()

next = __next__ # allows user to call without a loop `val = trials.next()`

def _checkFinished(self):
"""checks if we are finished
Updates attribute: `finished`
Expand Down Expand Up @@ -1513,6 +1519,8 @@ def __next__(self):
else:
raise StopIteration

next = __next__ # allows user to call without a loop `val = trials.next()`

def _startNewPass(self):
"""Create a new iteration of the running staircases for this pass.
Expand Down
6 changes: 6 additions & 0 deletions psychopy/data/trial.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,8 @@ def __next__(self):
logging.exp(msg % vals, obj=self.thisTrial)
return self.thisTrial

next = __next__ # allows user to call without a loop `val = trials.next()`

def getFutureTrial(self, n=1):
"""Returns the condition for n trials into the future,
without advancing the trials. A negative n returns a previous (past)
Expand Down Expand Up @@ -1020,6 +1022,8 @@ def __next__(self):
logging.exp(msg % vals, obj=self.thisTrial)
return self.thisTrial

next = __next__ # allows user to call without a loop `val = trials.next()`

def getFutureTrial(self, n=1):
"""Returns the condition for n trials into the future, without
advancing the trials. Returns 'None' if attempting to go beyond
Expand Down Expand Up @@ -1516,6 +1520,8 @@ def __next__(self):
logging.exp(msg % vals, obj=self.thisTrial)
return self.thisTrial

next = __next__ # allows user to call without a loop `val = trials.next()`

def getCurrentTrialPosInDataHandler(self):
# if there's no trial weights, then the current position is simply
# [trialIndex, nRepetition]
Expand Down

0 comments on commit c44621a

Please sign in to comment.