|
|
ae01b1d |
From 0f0d556de276531609ac50de58c8067fcf93cf86 Mon Sep 17 00:00:00 2001
|
|
|
ae01b1d |
From: Igor Gnatenko <i.gnatenko.brain@gmail.com>
|
|
|
ae01b1d |
Date: Sat, 12 Dec 2015 16:02:08 +0100
|
|
|
ae01b1d |
Subject: [PATCH 2/5] py3: print_function
|
|
|
ae01b1d |
|
|
|
ae01b1d |
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
|
|
|
ae01b1d |
---
|
|
|
ae01b1d |
src/Quest.py | 20 +++++++++++---------
|
|
|
ae01b1d |
1 file changed, 11 insertions(+), 9 deletions(-)
|
|
|
ae01b1d |
|
|
|
ae01b1d |
diff --git a/src/Quest.py b/src/Quest.py
|
|
|
ae01b1d |
index f84a8b4..751b277 100644
|
|
|
ae01b1d |
--- a/src/Quest.py
|
|
|
ae01b1d |
+++ b/src/Quest.py
|
|
|
ae01b1d |
@@ -31,6 +31,8 @@
|
|
|
ae01b1d |
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
|
|
ae01b1d |
# DAMAGE.
|
|
|
ae01b1d |
|
|
|
ae01b1d |
+from __future__ import print_function
|
|
|
ae01b1d |
+
|
|
|
ae01b1d |
__all__ = ['QuestObject']
|
|
|
ae01b1d |
|
|
|
ae01b1d |
import math
|
|
|
ae01b1d |
@@ -169,7 +171,7 @@ class QuestObject:
|
|
|
ae01b1d |
iBetaMean=num.sum(p2/beta2)/p
|
|
|
ae01b1d |
iBetaSd=math.sqrt(num.sum(p2/beta2**2)/p-(num.sum(p2/beta2)/p)**2)
|
|
|
ae01b1d |
stream.write('%5.2f %5.2f %4.1f %4.1f %6.3f\n'%(t,sd,1/iBetaMean,betaSd,self.gamma))
|
|
|
ae01b1d |
- print 'Now re-analyzing with beta as a free parameter. . . .'
|
|
|
ae01b1d |
+ print('Now re-analyzing with beta as a free parameter. . . .')
|
|
|
ae01b1d |
if stream is None:
|
|
|
ae01b1d |
stream=sys.stdout
|
|
|
ae01b1d |
stream.write('logC sd beta sd gamma\n');
|
|
|
ae01b1d |
@@ -418,7 +420,7 @@ def demo():
|
|
|
ae01b1d |
psychometric method. Percept Psychophys, 33 (2), 113-20.
|
|
|
ae01b1d |
"""
|
|
|
ae01b1d |
|
|
|
ae01b1d |
- print 'The intensity scale is abstract, but usually we think of it as representing log contrast.'
|
|
|
ae01b1d |
+ print('The intensity scale is abstract, but usually we think of it as representing log contrast.')
|
|
|
ae01b1d |
|
|
|
ae01b1d |
tActual = None
|
|
|
ae01b1d |
while tActual is None:
|
|
|
ae01b1d |
@@ -460,27 +462,27 @@ def demo():
|
|
|
ae01b1d |
# Simulate a trial
|
|
|
ae01b1d |
timeSplit=time.time(); # omit simulation and printing from reported time/trial.
|
|
|
ae01b1d |
response=q.simulate(tTest,tActual)
|
|
|
ae01b1d |
- print 'Trial %3d at %4.1f is %s'%(k+1,tTest,wrongRight[int(response)])
|
|
|
ae01b1d |
+ print('Trial %3d at %4.1f is %s'%(k+1,tTest,wrongRight[int(response)]))
|
|
|
ae01b1d |
timeZero=timeZero+time.time()-timeSplit;
|
|
|
ae01b1d |
|
|
|
ae01b1d |
# Update the pdf
|
|
|
ae01b1d |
q.update(tTest,response);
|
|
|
ae01b1d |
|
|
|
ae01b1d |
# Print results of timing.
|
|
|
ae01b1d |
- print '%.0f ms/trial'%(1000*(time.time()-timeZero)/trialsDesired)
|
|
|
ae01b1d |
+ print('%.0f ms/trial'%(1000*(time.time()-timeZero)/trialsDesired))
|
|
|
ae01b1d |
|
|
|
ae01b1d |
# Get final estimate.
|
|
|
ae01b1d |
t=q.mean()
|
|
|
ae01b1d |
sd=q.sd()
|
|
|
ae01b1d |
- print 'Mean threshold estimate is %4.2f +/- %.2f'%(t,sd)
|
|
|
ae01b1d |
+ print('Mean threshold estimate is %4.2f +/- %.2f'%(t,sd))
|
|
|
ae01b1d |
#t=QuestMode(q);
|
|
|
ae01b1d |
#print 'Mode threshold estimate is %4.2f'%t
|
|
|
ae01b1d |
|
|
|
ae01b1d |
- print '\nQuest beta analysis. Beta controls the steepness of the Weibull function.\n'
|
|
|
ae01b1d |
+ print('\nQuest beta analysis. Beta controls the steepness of the Weibull function.\n')
|
|
|
ae01b1d |
q.beta_analysis()
|
|
|
ae01b1d |
- print 'Actual parameters of simulated observer:'
|
|
|
ae01b1d |
- print 'logC beta gamma'
|
|
|
ae01b1d |
- print '%5.2f %4.1f %5.2f'%(tActual,q.beta,q.gamma)
|
|
|
ae01b1d |
+ print('Actual parameters of simulated observer:')
|
|
|
ae01b1d |
+ print('logC beta gamma')
|
|
|
ae01b1d |
+ print('%5.2f %4.1f %5.2f'%(tActual,q.beta,q.gamma))
|
|
|
ae01b1d |
|
|
|
ae01b1d |
if __name__ == '__main__':
|
|
|
ae01b1d |
demo() # run the demo
|
|
|
ae01b1d |
--
|
|
|
ae01b1d |
2.6.4
|
|
|
ae01b1d |
|