Skip to content

Commit

Permalink
criterion fix > vs >=
Browse files Browse the repository at this point in the history
If it's going to count number of instances then the comparison needs to be >= rather than just >0
  • Loading branch information
jfkominsky committed Aug 30, 2024
1 parent d2d50b5 commit 094977f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion PyHab/PyHabClass.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ def checkStop(self, blockName):
consecOffTimes.append(completeVerbose[m]['duration'])
m = m+1
# This is a very pythonic way of doing it, but checks if enough of the assembled consecutive off-times are above threshold.
return len([x for x in consecOffTimes if x >= self.habCrit[blockName]]) > self.blockList[blockName]['metCritDivisor']
return len([x for x in consecOffTimes if x >= self.habCrit[blockName]]) >= self.blockList[blockName]['metCritDivisor']
elif self.blockList[blockName]['metCritStatic'] == 'Moving' or (self.habCount[blockName]-self.blockList[blockName]['setCritWindow']) % self.blockList[blockName]['metCritWindow'] == 0:
habIndex = self.habCount[blockName] - self.blockList[blockName]['metCritWindow']
# As above
Expand Down
3 changes: 1 addition & 2 deletions testing/test_pyhab.py
Original file line number Diff line number Diff line change
Expand Up @@ -1595,7 +1595,6 @@ def test_fixedlength_crosstrial(self):
blockName = 'D'
assert self.dataInst.habCount[blockName] >= self.dataInst.habSetWhen[blockName] + self.dataInst.blockList[blockName]['metCritWindow'] - 1

assert self.dataInst.checkStop('D') == True
habIndex = self.dataInst.habCount[blockName] - self.dataInst.blockList[blockName]['metCritWindow']

targetTrials = []
Expand Down Expand Up @@ -1654,7 +1653,7 @@ def test_fixedlength_crosstrial(self):
consecOffTimes.append(completeVerbose[m]['duration'])
m = m + 1
assert 5.5 in consecOffTimes
assert len([x for x in consecOffTimes if x >= self.dataInst.habCrit['D']]) > self.dataInst.blockList['D']['metCritDivisor']
assert len([x for x in consecOffTimes if x >= self.dataInst.habCrit['D']]) >= self.dataInst.blockList['D']['metCritDivisor']
assert self.dataInst.checkStop('D') == True

# additional test for situation where there need to be N gaze-off events above threshold.
Expand Down

0 comments on commit 094977f

Please sign in to comment.