Skip to content

Commit

Permalink
RF: continuing import refinements
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremygray committed Dec 7, 2015
1 parent 131b59f commit c2f2809
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 31 deletions.
6 changes: 4 additions & 2 deletions psychopy/app/_psychopyApp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 2 additions & 3 deletions psychopy/app/psychopyApp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions psychopy/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
27 changes: 15 additions & 12 deletions psychopy/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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))
"""

Expand Down
17 changes: 10 additions & 7 deletions psychopy/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand All @@ -23,7 +21,6 @@
havePygame = True
except:
havePygame = False

try:
import pyglet
havePyglet = True
Expand All @@ -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
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 2 additions & 0 deletions psychopy/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions psychopy/gamma.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions psychopy/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions psychopy/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions psychopy/locale_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions psychopy/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 6 additions & 5 deletions psychopy/makeMovies.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c2f2809

Please sign in to comment.