diff --git a/psychopy/app/_psychopyApp.py b/psychopy/app/_psychopyApp.py index f20fa3beea8..1c1c1a91069 100755 --- a/psychopy/app/_psychopyApp.py +++ b/psychopy/app/_psychopyApp.py @@ -22,8 +22,10 @@ import wx.lib.agw.advancedsplash as AS #NB keep imports to a minimum here because splash screen has not yet shown #e.g. coder and builder are imported during app.__init__ because they take a while -from psychopy import preferences, logging#needed by splash screen for the path to resources/psychopySplash.png -from psychopy.app import connections + +#needed by splash screen for the path to resources/psychopySplash.png +from psychopy import preferences, logging, __version__ +from . import connections import sys, os, threading # knowing if the user has admin priv is generally a good idea for security. diff --git a/psychopy/app/psychopyApp.py b/psychopy/app/psychopyApp.py index 94150aa914a..a6c299853eb 100755 --- a/psychopy/app/psychopyApp.py +++ b/psychopy/app/psychopyApp.py @@ -7,8 +7,7 @@ from __future__ import absolute_import, print_function import sys -import psychopy -from psychopy.app._psychopyApp import PsychoPyApp +from psychopy.app._psychopyApp import PsychoPyApp, __version__ #NB the PsychoPyApp classes moved to _psychopyApp.py as of version 1.78.00 #to allow for better upgrading possibilities from the mac app bundle. this file @@ -24,7 +23,7 @@ sys.exit() if '-v' in sys.argv or '--version' in sys.argv: info = 'PsychoPy2, version %s (c)Jonathan Peirce 2015, GNU GPL license' - print(info % psychopy.__version__) + print(info % __version__) sys.exit() if '-h' in sys.argv or '--help' in sys.argv: print("""Starts the PsychoPy2 application. diff --git a/psychopy/core.py b/psychopy/core.py index be8b266e6df..2d9211277d4 100644 --- a/psychopy/core.py +++ b/psychopy/core.py @@ -9,7 +9,8 @@ import sys, threading import subprocess, shlex -from psychopy.clock import MonotonicClock, Clock, CountdownTimer, wait, monotonicClock, getAbsTime +from psychopy.clock import (MonotonicClock, Clock, CountdownTimer, + wait, monotonicClock, getAbsTime) # always safe to call rush, even if its not going to do anything for a particular OS from psychopy.platform_specific import rush from psychopy import logging @@ -130,7 +131,6 @@ def complete(self): if self.win: self.win.recordFrameIntervals = self._winWasRecordingIntervals if timeRemaining<0: - import logging#we only do this if we need it - circular import logging.warn('We overshot the intended duration of %s by %.4fs. The intervening code took too long to execute.' %(self.name, abs(timeRemaining))) return 0 else: diff --git a/psychopy/data.py b/psychopy/data.py index c8073409924..c06ad240cf5 100644 --- a/psychopy/data.py +++ b/psychopy/data.py @@ -4,17 +4,12 @@ # Copyright (C) 2015 Jonathan Peirce # Distributed under the terms of the GNU General Public License (GPL). -from psychopy import logging -from psychopy.tools.arraytools import extendArr, shuffleArray -from psychopy.tools.fileerrortools import handleFileCollision -from psychopy.tools.filetools import openOutputFile, genDelimiter -import psychopy +from __future__ import absolute_import + from pandas import DataFrame, read_csv import cPickle, string, sys, os, time, copy import numpy from scipy import optimize, special -from contrib.quest import QuestObject #used for QuestHandler -from contrib.psi import PsiObject #used for PsiHandler import inspect #so that Handlers can find the script that called them import codecs import weakref @@ -30,6 +25,14 @@ except ImportError: haveOpenpyxl=False +from psychopy import logging +from psychopy.tools.arraytools import extendArr, shuffleArray +from psychopy.tools.fileerrortools import handleFileCollision +from psychopy.tools.filetools import openOutputFile, genDelimiter +import psychopy +from psychopy.contrib.quest import QuestObject #used for QuestHandler +from psychopy.contrib.psi import PsiObject #used for PsiHandler + _experiments=weakref.WeakValueDictionary() _nonalphanumeric_re = re.compile(r'\W') # will match all bad var name chars @@ -3342,13 +3345,13 @@ class PsiHandler(StairHandler): Because Psi is a Bayesian method, it can be initialized with a prior from existing research. A function to save the posterior over Lambda as a Numpy binary file is included. - - Kontsevich & Tyler (1999) specify their psychometric function in terms of d'. PsiHandler avoids this - and treats all parameters with respect to stimulus intensity. Specifically, the forms of the psychometric + + Kontsevich & Tyler (1999) specify their psychometric function in terms of d'. PsiHandler avoids this + and treats all parameters with respect to stimulus intensity. Specifically, the forms of the psychometric function assumed for Yes/No and Two Alternative Forced Choice (2AFC) are, respectively: - + Y(x) = .5 * delta + (1 - delta) * norm.cdf(x, mean=alpha, sd=beta) - + Y(x) = .5 * delta + (1 - delta) * (.5 + .5 * norm.cdf(x, mean=alpha, sd=beta)) """ diff --git a/psychopy/event.py b/psychopy/event.py index d164e17fc47..86df34e1eab 100644 --- a/psychopy/event.py +++ b/psychopy/event.py @@ -8,11 +8,9 @@ # 01/2011 modified by Dave Britton to get mouse event timing +from __future__ import absolute_import + import sys, time, copy -import psychopy.core -from psychopy.tools.monitorunittools import cm2pix, deg2pix, pix2cm, pix2deg -from psychopy import logging -from psychopy.constants import NOT_STARTED import string, numpy #try to import pyglet & pygame and hope the user has at least one of them! @@ -23,7 +21,6 @@ havePygame = True except: havePygame = False - try: import pyglet havePyglet = True @@ -32,6 +29,12 @@ if havePygame: usePygame=True#will become false later if win not initialised else: usePygame=False +import psychopy.core +from psychopy.tools.monitorunittools import cm2pix, deg2pix, pix2cm, pix2deg +from psychopy import logging +from psychopy.constants import NOT_STARTED + + if havePyglet: from pyglet.window.mouse import LEFT, MIDDLE, RIGHT # takes ~250ms, so do it now global _keyBuffer @@ -485,9 +488,9 @@ def getWheelRel(self): def getVisible(self): """Gets the visibility of the mouse (1 or 0) """ - if usePygame: + if usePygame: return mouse.get_visible() - else: + else: print("Getting the mouse visibility is not supported under pyglet, but you can set it anyway") def setVisible(self,visible): diff --git a/psychopy/filters.py b/psychopy/filters.py index 97488892f3e..b0ca6433756 100644 --- a/psychopy/filters.py +++ b/psychopy/filters.py @@ -6,6 +6,8 @@ # Copyright (C) 2015 Jonathan Peirce # Distributed under the terms of the GNU General Public License (GPL). +from __future__ import absolute_import + import numpy from numpy.fft import fft2, ifft2, fftshift, ifftshift from psychopy import logging diff --git a/psychopy/gamma.py b/psychopy/gamma.py index 3e30a53744f..d5c13965384 100644 --- a/psychopy/gamma.py +++ b/psychopy/gamma.py @@ -5,6 +5,8 @@ # Copyright (C) 2015 Jonathan Peirce # Distributed under the terms of the GNU General Public License (GPL). +from __future__ import absolute_import + import numpy, sys, platform, ctypes, ctypes.util import pyglet from psychopy import logging diff --git a/psychopy/gui.py b/psychopy/gui.py index f68f5e6cf29..aba9e0203d0 100644 --- a/psychopy/gui.py +++ b/psychopy/gui.py @@ -4,6 +4,8 @@ # Copyright (C) 2015 Jonathan Peirce # Distributed under the terms of the GNU General Public License (GPL). +from __future__ import absolute_import + from psychopy import logging import wx import numpy diff --git a/psychopy/info.py b/psychopy/info.py index 802a0a5e86b..2918b79bbac 100644 --- a/psychopy/info.py +++ b/psychopy/info.py @@ -8,6 +8,8 @@ # Copyright (C) 2015 Jonathan Peirce # Distributed under the terms of the GNU General Public License (GPL). +from __future__ import absolute_import + import sys, os, platform from psychopy import visual, logging, core, data, web diff --git a/psychopy/locale_setup.py b/psychopy/locale_setup.py index 6693ce344cf..cbb8510e2b7 100644 --- a/psychopy/locale_setup.py +++ b/psychopy/locale_setup.py @@ -13,6 +13,8 @@ create multiple versions of an experiment. """ +from __future__ import absolute_import + import platform mac_ver = platform.mac_ver()[0] # e.g., '10.9.5' or '' for non-Mac diff --git a/psychopy/logging.py b/psychopy/logging.py index abd62df730c..14e6cd6628c 100644 --- a/psychopy/logging.py +++ b/psychopy/logging.py @@ -28,6 +28,8 @@ #python logging module but it's simpler (no threading) and maintaining a stack #of log entries for later writing (don't want files written while drawing) +from __future__ import absolute_import + from os import path import sys, codecs, weakref from psychopy import clock diff --git a/psychopy/makeMovies.py b/psychopy/makeMovies.py index ec6da0ee16b..2edd90331e6 100644 --- a/psychopy/makeMovies.py +++ b/psychopy/makeMovies.py @@ -9,23 +9,24 @@ building an optimised gif palette (makeRGBhistogram, makePalette, rgb2palette are very heavily based on his code). """ -from psychopy import logging + +from __future__ import absolute_import + import string, time, tempfile, os, glob, random try: from PIL import Image, ImageChops - from PIL.GifImagePlugin import getheader, getdata #part of PIL + from PIL.GifImagePlugin import getheader, getdata except ImportError: import Image, ImageChops - from GifImagePlugin import getheader, getdata #part of PIL - + from GifImagePlugin import getheader, getdata try: import pymedia.video.vcodec as vcodec havePyMedia=True except: havePyMedia=False - import numpy +from psychopy import logging # -------------------------------------------------------------------- # straightforward delta encoding