本文整理汇总了Python中psychopy.logging.warning函数的典型用法代码示例。如果您正苦于以下问题:Python warning函数的具体用法?Python warning怎么用?Python warning使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了warning函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: onResize
def onResize(self, width, height):
"""A method that will be called if the window detects a resize event
"""
logging.warning("dispatchEvents() method in {} was called "
"but is not implemented. Is it needed?"
.format(self.win.winType)
)
示例2: __init__
def __init__(self,
win,
contrast=1.0,
gamma=None,
nEntries=256,
mode='bits++',
rampType = 'configFile'):
self.win = win
self.contrast=contrast
self.nEntries=nEntries
self.mode = mode
self.method = 'fast' #used to allow setting via USB which was 'slow'
self.gammaCorrect = 'software' #Bits++ doesn't do its own correction so we need to
#import pyglet.GL late so that we can import bits.py without it initially
global GL, visual
from psychopy import visual
import pyglet.gl as GL
if self.gammaCorrect=='software':
if gamma is None:
self.gamma = win.gamma #inherit from window
elif len(gamma)>2: # [Lum,R,G,B] or [R,G,B]
self.gamma=gamma[-3:]
else:
self.gamma = [gamma, gamma, gamma]
if init():
setVideoMode(NOGAMMACORRECT|VIDEOENCODEDCOMMS)
self.initialised=True
logging.debug('found and initialised bits++')
else:
self.initialised=False
logging.warning("couldn't initialise bits++")
#do the processing
self._HEADandLUT = np.zeros((524,1,3),np.uint8)
self._HEADandLUT[:12,:,0] = np.asarray([ 36, 63, 8, 211, 3, 112, 56, 34,0,0,0,0]).reshape([12,1])#R
self._HEADandLUT[:12,:,1] = np.asarray([ 106, 136, 19, 25, 115, 68, 41, 159,0,0,0,0]).reshape([12,1])#G
self._HEADandLUT[:12,:,2] = np.asarray([ 133, 163, 138, 46, 164, 9, 49, 208,0,0,0,0]).reshape([12,1])#B
self.LUT=np.zeros((256,3),'d') #just a place holder
self.setLUT()#this will set self.LUT and update self._LUTandHEAD
self._setupShaders()
#replace window methods with our custom ones
self.win._prepareFBOrender = self._prepareFBOrender
self.win._finishFBOrender = self._finishFBOrender
self.win._afterFBOrender = self._afterFBOrender
#set gamma of the window to the identity LUT
if rampType == 'configFile':
#now check that we have a valid configuration of the box
self.config = Config(self)
#check that this matches the prev config for our graphics card etc
ok=False #until we find otherwise
ok = self.config.quickCheck()
if ok:
self.win.gammaRamp = self.config.identityLUT
else:
rampType = None
if not rampType == 'configFile': #'this must NOT be an `else` from the above `if` because can be overidden
#possibly we were given a numerical rampType (as in the :func:`psychopy.gamma.setGamma()`)
self.win.winHandle.setGamma(self.win.winHandle, rampType=rampType)
示例3: lms2rgb
def lms2rgb(lms_Nx3, conversionMatrix=None):
"""Convert from cone space (Long, Medium, Short) to RGB.
Requires a conversion matrix, which will be generated from generic
Sony Trinitron phosphors if not supplied (note that you will not get
an accurate representation of the color space unless you supply a
conversion matrix)
usage::
rgb_Nx3 = lms2rgb(dkl_Nx3(el,az,radius), conversionMatrix)
"""
lms_3xN = numpy.transpose(lms_Nx3)#its easier to use in the other orientation!
if conversionMatrix==None:
cones_to_rgb = numpy.asarray([ \
#L M S
[ 4.97068857, -4.14354132, 0.17285275],#R
[-0.90913894, 2.15671326, -0.24757432],#G
[-0.03976551, -0.14253782, 1.18230333]#B
])
logging.warning('This monitor has not been color-calibrated. Using default LMS conversion matrix.')
else: cones_to_rgb=conversionMatrix
rgb_to_cones = numpy.linalg.pinv(cones_to_rgb)#get inverse
rgb = numpy.dot(cones_to_rgb, lms_3xN)
return numpy.transpose(rgb)#return in the shape we received it
示例4: calibrateZero
def calibrateZero(self):
"""Perform a calibration to zero light.
For early versions of the ColorCAL this had to be called after
connecting to the device. For later versions the dark calibration
was performed at the factory and stored in non-volatile memory.
You can check if you need to run a calibration with::
ColorCAL.getNeedsCalibrateZero()
"""
val = self.sendMessage(b"UZC", timeout=1.0)
if val == 'OK00':
pass
elif val == 'ER11':
logging.error(
"Could not calibrate ColorCAL2. Is it properly covered?")
return False
else: # unlikely
logging.warning(
"Received surprising result from ColorCAL2: %s" % val)
return False
# then take a measurement to see if we are close to zero lum (ie is it
# covered?)
self.ok, x, y, z = self.measure()
if y > 3:
logging.error('There seems to be some light getting to the '
'detector. It should be well-covered for zero '
'calibration')
return False
self._zeroCalibrated = True
self.calibMatrix = self.getCalibMatrix()
return True
示例5: __init__
def __init__(self,
win,
contrast=1.0,
gamma=[1.0,1.0,1.0],
nEntries=256,
mode='bits++',):
self.win = win
self.contrast=contrast
self.nEntries=nEntries
self.mode = mode
self.method = 'fast' #used to allow setting via USB which was 'slow'
if len(gamma)>2: # [Lum,R,G,B] or [R,G,B]
self.gamma=gamma[-3:]
else:
self.gamma = [gamma, gamma, gamma]
if init():
setVideoMode(NOGAMMACORRECT|VIDEOENCODEDCOMMS)
self.initialised=True
logging.debug('found and initialised bits++')
else:
self.initialised=False
logging.warning("couldn't initialise bits++")
#do the processing
self._HEADandLUT = np.zeros((524,1,3),np.uint8)
self._HEADandLUT[:12,:,0] = np.asarray([ 36, 63, 8, 211, 3, 112, 56, 34,0,0,0,0]).reshape([12,1])#R
self._HEADandLUT[:12,:,1] = np.asarray([ 106, 136, 19, 25, 115, 68, 41, 159,0,0,0,0]).reshape([12,1])#G
self._HEADandLUT[:12,:,2] = np.asarray([ 133, 163, 138, 46, 164, 9, 49, 208,0,0,0,0]).reshape([12,1])#B
self.LUT=np.zeros((256,3),'d') #just a place holder
self.setLUT()#this will set self.LUT and update self._LUTandHEAD
self._setupShaders()
示例6: __init__
def __init__(self, name='', autoLog=True):
self.name = name
self.status = NOT_STARTED
self.autoLog = autoLog
if self.autoLog:
logging.warning("%s is calling MinimalStim.__init__() with autolog=True. Set autoLog to True only at the end of __init__())" \
%(self.__class__.__name__))
示例7: pavlovia
def pavlovia(self, proj):
global knownProjects
self.__dict__['pavlovia'] = proj
if not hasattr(proj, 'attributes'):
return
thisID = proj.attributes['path_with_namespace']
if thisID in knownProjects \
and os.path.exists(knownProjects[thisID]['localRoot']):
rememberedProj = knownProjects[thisID]
if rememberedProj['idNumber'] != proj.attributes['id']:
logging.warning("Project {} has changed gitlab ID since last "
"use (was {} now {})"
.format(thisID,
rememberedProj['idNumber'],
proj.attributes['id']))
self.update(rememberedProj)
elif 'localRoot' in self:
# this means the local root was set before the remote was known
self['id'] = proj.attributes['path_with_namespace']
self['idNumber'] = proj.attributes['id']
knownProjects[self['id']] = self
else:
self['localRoot'] = ''
self['id'] = proj.attributes['path_with_namespace']
self['idNumber'] = proj.attributes['id']
self['remoteSSH'] = proj.ssh_url_to_repo
self['remoteHTTPS'] = proj.http_url_to_repo
示例8: __init__
def __init__(self,
port=None,
sendBreak=False,
smoothing=False,
bufferSize=262144):
# if we're trying to send the break signal then presumably the device
# is sleeping
if sendBreak:
checkAwake = False
else:
checkAwake = True
# run initialisation; parity = enable parity checking
super(BlackBoxToolkit, self).__init__(port,
baudrate=230400, eol="\r\n",
parity='N',
pauseDuration=1.0, # 1 second pause!! slow device
checkAwake=checkAwake)
if sendBreak:
self.sendBreak()
time.sleep(3.0) # give time to reset
if smoothing == False:
# For use with CRT monitors which require smoothing. LCD monitors do not.
# Remove smoothing for optos, but keep mic smoothing - refer to BBTK handbook re: mic smoothing latency
# Important to remove smoothing for optos, as smoothing adds 20ms delay to timing.
logging.info("Opto sensor smoothing removed. Mic1 and Mic2 smoothing still active.")
self.setSmoothing('11000000')
self.pause()
try: # set buffer size - can make proportional to size of data (32 bytes per line * events)+1000
self.com.set_buffer_size(bufferSize)
except Exception:
logging.warning("Could not set buffer size. The default buffer size for Windows is 4096 bytes.")
示例9: add
def add(self, thisType, value, position=None):
"""Add data to an existing data type (and add a new one if necess)
"""
if not thisType in self:
self.addDataType(thisType)
if position is None:
# 'ran' is always the first thing to update
repN = sum(self['ran'][self.trials.thisIndex])
if thisType != 'ran':
# because it has already been updated
repN -= 1
# make a list where 1st digit is trial number
position = [self.trials.thisIndex]
position.append(repN)
# check whether data falls within bounds
posArr = np.asarray(position)
shapeArr = np.asarray(self.dataShape)
if not np.alltrue(posArr < shapeArr):
# array isn't big enough
logging.warning('need a bigger array for: ' + thisType)
# not implemented yet!
self[thisType] = extendArr(self[thisType], posArr)
# check for ndarrays with more than one value and for non-numeric data
if (self.isNumeric[thisType] and
((type(value) == np.ndarray and len(value) > 1) or
(type(value) not in [float, int]))):
self._convertToObjectArray(thisType)
# insert the value
self[thisType][position[0], int(position[1])] = value
示例10: rgb2lms
def rgb2lms(rgb_Nx3, conversionMatrix=None):
"""Convert from RGB to cone space (LMS).
Requires a conversion matrix, which will be generated from generic
Sony Trinitron phosphors if not supplied (note that you will not get
an accurate representation of the color space unless you supply a
conversion matrix)
usage::
lms_Nx3 = rgb2lms(rgb_Nx3(el,az,radius), conversionMatrix)
"""
# its easier to use in the other orientation!
rgb_3xN = numpy.transpose(rgb_Nx3)
if conversionMatrix is None:
cones_to_rgb = numpy.asarray([
# L M S
[4.97068857, -4.14354132, 0.17285275], # R
[-0.90913894, 2.15671326, -0.24757432], # G
[-0.03976551, -0.14253782, 1.18230333]]) # B
logging.warning('This monitor has not been color-calibrated. '
'Using default LMS conversion matrix.')
else:
cones_to_rgb = conversionMatrix
rgb_to_cones = numpy.linalg.inv(cones_to_rgb)
lms = numpy.dot(rgb_to_cones, rgb_3xN)
return numpy.transpose(lms) # return in the shape we received it
示例11: _getNextFrame
def _getNextFrame(self):
# get next frame info ( do not decode frame yet)
while self.status == PLAYING:
if self._video_stream.grab():
self._prev_frame_index = self._next_frame_index
self._prev_frame_sec = self._next_frame_sec
self._next_frame_index = self._video_stream.get(cv2.cv.CV_CAP_PROP_POS_FRAMES)
if self._requested_fps and self._no_audio:
self._next_frame_sec = self._next_frame_index/self._requested_fps#*self._video_stream.get(cv2.cv.CV_CAP_PROP_POS_MSEC)/1000.0
else:
self._next_frame_sec = self._video_stream.get(cv2.cv.CV_CAP_PROP_POS_MSEC)/1000.0
self._video_perc_done = self._video_stream.get(cv2.cv.CV_CAP_PROP_POS_AVI_RATIO)
self._next_frame_displayed = False
if self.getTimeToNextFrameDraw() > -self._inter_frame_interval/2.0:
return self._next_frame_sec
else:
self.nDroppedFrames += 1
if self.nDroppedFrames < reportNDroppedFrames:
logging.warning("MovieStim2 dropping video frame index: %d"%(self._next_frame_index))
elif self.nDroppedFrames == reportNDroppedFrames:
logging.warning("Multiple Movie frames have "
"occurred - I'll stop bothering you "
"about them!")
else:
self._onEos()
break
示例12: push
def push(self, syncPanel=None, progressHandler=None):
"""Push to remote from local copy of the repository
Parameters
----------
syncPanel
progressHandler
Returns
-------
1 if successful
-1 if project deleted on remote
"""
if syncPanel:
syncPanel.statusAppend("\nPushing changes to remote...")
origin = self.repo.remotes.origin
try:
info = self.repo.git.push() # progress=progressHandler
except git.exc.GitCommandError as e:
if ("The project you were looking for could not be found" in
traceback.format_exc()):
# we are pointing to a project at pavlovia but it doesn't exist
# suggest we create it
logging.warning("Project not found on gitlab.pavlovia.org")
return MISSING_REMOTE
else:
raise e
logging.debug('push report: {}'.format(info))
if syncPanel:
syncPanel.statusAppend("done")
if info:
syncPanel.statusAppend("\n{}".format(info))
return 1
示例13: sendUsageStats
def sendUsageStats(app=None):
"""Sends anonymous, very basic usage stats to psychopy server:
the version of PsychoPy
the system used (platform and version)
the date
"""
v = psychopy.__version__
dateNow = time.strftime("%Y-%m-%d_%H:%M")
miscInfo = ''
# get platform-specific info
if sys.platform == 'darwin':
OSXver, junk, architecture = platform.mac_ver()
systemInfo = "OSX_%s_%s" % (OSXver, architecture)
elif sys.platform.startswith('linux'):
systemInfo = '%s_%s_%s' % (
'Linux',
':'.join([x for x in platform.dist() if x != '']),
platform.release())
if len(systemInfo) > 30: # if it's too long PHP/SQL fails to store!?
systemInfo = systemInfo[0:30]
elif sys.platform == 'win32':
systemInfo = "win32_v" + platform.version()
else:
systemInfo = platform.system() + platform.release()
u = "http://www.psychopy.org/usage.php?date=%s&sys=%s&version=%s&misc=%s"
URL = u % (dateNow, systemInfo, v, miscInfo)
try:
page = requests.get(URL, proxies=web.proxies) # proxies
except Exception:
logging.warning("Couldn't connect to psychopy.org\n"
"Check internet settings (and proxy "
"setting in PsychoPy Preferences.")
示例14: _setVersion
def _setVersion(version):
"""
Sets the version to be used for compiling using the useVersion function
Parameters
----------
version: string
The version requested
"""
# Set version
if version:
from psychopy import useVersion
useVersion(version)
global logging
from psychopy import logging
if __name__ != '__main__' and version not in [None, 'None', 'none', '']:
version = None
msg = "You cannot set version by calling compileScript() manually. Setting 'version' to None."
logging.warning(msg)
return version
示例15: OnDropFiles
def OnDropFiles(self, x, y, filenames):
logging.debug('PsychoPyBuilder: received dropped files: %s' % filenames)
for filename in filenames:
if filename.endswith('.psyexp') or filename.lower().endswith('.py'):
self.builder.fileOpen(filename=filename)
else:
logging.warning('dropped file ignored: did not end in .psyexp or .py')