Clean up Errors for CodeQL analyzer
CodeQL identified some errors and warnings, which this commit cleans up.
This commit is contained in:
parent
329423f525
commit
03ea368454
@ -8,7 +8,6 @@ This example uses the isosurface function to convert a scalar field
|
||||
import initExample
|
||||
|
||||
import numpy as np
|
||||
from pyqtgraph.Qt import QtCore, QtGui
|
||||
import pyqtgraph as pg
|
||||
import pyqtgraph.opengl as gl
|
||||
|
||||
@ -29,7 +28,6 @@ def psi(i, j, k, offset=(25, 25, 50)):
|
||||
y = j-offset[1]
|
||||
z = k-offset[2]
|
||||
th = np.arctan2(z, np.hypot(x, y))
|
||||
phi = np.arctan2(y, x)
|
||||
r = np.sqrt(x**2 + y**2 + z **2)
|
||||
a0 = 1
|
||||
ps = (1./81.) * 1./(6.*np.pi)**0.5 * (1./a0)**(3/2) * (r/a0)**2 * np.exp(-r/(3*a0)) * (3 * np.cos(th)**2 - 1)
|
||||
|
@ -9,7 +9,6 @@ import initExample
|
||||
|
||||
import numpy as np
|
||||
import pyqtgraph as pg
|
||||
from pyqtgraph.Qt import QtCore, QtGui
|
||||
import pyqtgraph.opengl as gl
|
||||
from pyqtgraph import functions as fn
|
||||
|
||||
@ -31,10 +30,8 @@ def psi(i, j, k, offset=(50,50,100)):
|
||||
y = j-offset[1]
|
||||
z = k-offset[2]
|
||||
th = np.arctan2(z, np.hypot(x, y))
|
||||
phi = np.arctan2(y, x)
|
||||
r = np.sqrt(x**2 + y**2 + z **2)
|
||||
a0 = 2
|
||||
#ps = (1./81.) * (2./np.pi)**0.5 * (1./a0)**(3/2) * (6 - r/a0) * (r/a0) * np.exp(-r/(3*a0)) * np.cos(th)
|
||||
ps = (1./81.) * 1./(6.*np.pi)**0.5 * (1./a0)**(3/2) * (r/a0)**2 * np.exp(-r/(3*a0)) * (3 * np.cos(th)**2 - 1)
|
||||
return ps
|
||||
|
||||
|
@ -8,6 +8,7 @@ Distributed under MIT/X11 license. See license.txt for more information.
|
||||
from .Qt import QtCore
|
||||
from math import atan2, hypot, degrees
|
||||
|
||||
|
||||
class Point(QtCore.QPointF):
|
||||
"""Extension of QPointF which adds a few missing methods."""
|
||||
|
||||
|
@ -7,7 +7,6 @@ Distributed under MIT/X11 license. See license.txt for more information.
|
||||
from math import acos, degrees
|
||||
from .Qt import QtGui, QtCore, QT_LIB
|
||||
from . import functions as fn
|
||||
import numpy as np
|
||||
|
||||
class Vector(QtGui.QVector3D):
|
||||
"""Extension of QVector3D which adds a few helpful methods."""
|
||||
|
@ -1,6 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import numpy as np
|
||||
from ..Qt import QtGui, QtCore, QtSvg, QT_LIB
|
||||
from ..Qt import QtGui, QtCore, QT_LIB
|
||||
from .. import functions as fn
|
||||
from ..graphicsItems.ROI import ROI
|
||||
from .. import SRTTransform, ItemGroup
|
||||
|
@ -67,10 +67,8 @@ def siScale(x, minVal=1e-25, allowUnicode=True):
|
||||
raise
|
||||
if abs(x) < minVal:
|
||||
m = 0
|
||||
x = 0
|
||||
else:
|
||||
m = int(clip_scalar(math.floor(math.log(abs(x))/math.log(1000)), -9.0, 9.0))
|
||||
|
||||
if m == 0:
|
||||
pref = ''
|
||||
elif m < -8 or m > 8:
|
||||
@ -82,7 +80,6 @@ def siScale(x, minVal=1e-25, allowUnicode=True):
|
||||
pref = SI_PREFIXES_ASCII[m+8]
|
||||
m1 = -3*m
|
||||
p = 10.**m1
|
||||
|
||||
return (p, pref)
|
||||
|
||||
|
||||
|
@ -2,7 +2,6 @@ from math import atan2, degrees
|
||||
from ..Qt import QtGui, QtCore
|
||||
from . import ArrowItem
|
||||
from ..functions import clip_scalar
|
||||
import numpy as np
|
||||
from ..Point import Point
|
||||
import weakref
|
||||
from .GraphicsObject import GraphicsObject
|
||||
|
@ -15,9 +15,9 @@ of how to build an ROI at the bottom of the file.
|
||||
from ..Qt import QtCore, QtGui
|
||||
import numpy as np
|
||||
#from numpy.linalg import norm
|
||||
from ..Point import *
|
||||
from ..Point import Point
|
||||
from ..SRTTransform import SRTTransform
|
||||
from math import atan2, cos, sin, hypot, radians, degrees
|
||||
from math import atan2, cos, sin, hypot, radians
|
||||
from .. import functions as fn
|
||||
from .GraphicsObject import GraphicsObject
|
||||
from .UIGraphicsItem import UIGraphicsItem
|
||||
@ -141,12 +141,13 @@ class ROI(GraphicsObject):
|
||||
maxBounds=None, snapSize=1.0, scaleSnap=False,
|
||||
translateSnap=False, rotateSnap=False, parent=None, pen=None,
|
||||
hoverPen=None, handlePen=None, handleHoverPen=None,
|
||||
movable=True, rotatable=True, resizable=True, removable=False):
|
||||
movable=True, rotatable=True, resizable=True, removable=False,
|
||||
aspectLocked=False):
|
||||
GraphicsObject.__init__(self, parent)
|
||||
self.setAcceptedMouseButtons(QtCore.Qt.NoButton)
|
||||
pos = Point(pos)
|
||||
size = Point(size)
|
||||
self.aspectLocked = False
|
||||
self.aspectLocked = aspectLocked
|
||||
self.translatable = movable
|
||||
self.rotatable = rotatable
|
||||
self.resizable = resizable
|
||||
@ -678,7 +679,7 @@ class ROI(GraphicsObject):
|
||||
|
||||
The format returned is a list of (name, pos) tuples.
|
||||
"""
|
||||
if index == None:
|
||||
if index is None:
|
||||
positions = []
|
||||
for h in self.handles:
|
||||
positions.append((h['name'], h['pos']))
|
||||
@ -691,7 +692,7 @@ class ROI(GraphicsObject):
|
||||
|
||||
The format returned is a list of (name, pos) tuples.
|
||||
"""
|
||||
if index == None:
|
||||
if index is None:
|
||||
positions = []
|
||||
for h in self.handles:
|
||||
positions.append((h['name'], h['item'].scenePos()))
|
||||
@ -1298,7 +1299,7 @@ class ROI(GraphicsObject):
|
||||
"""Return global transformation (rotation angle+translation) required to move
|
||||
from relative state to current state. If relative state isn't specified,
|
||||
then we use the state of the ROI when mouse is pressed."""
|
||||
if relativeTo == None:
|
||||
if relativeTo is None:
|
||||
relativeTo = self.preMoveState
|
||||
st = self.getState()
|
||||
|
||||
@ -1941,8 +1942,7 @@ class CircleROI(EllipseROI):
|
||||
if radius is None:
|
||||
raise TypeError("Must provide either size or radius.")
|
||||
size = (radius*2, radius*2)
|
||||
EllipseROI.__init__(self, pos, size, **args)
|
||||
self.aspectLocked = True
|
||||
EllipseROI.__init__(self, pos, size, aspectLocked=True, **args)
|
||||
|
||||
def _addHandles(self):
|
||||
self.addScaleHandle([0.5*2.**-0.5 + 0.5, 0.5*2.**-0.5 + 0.5], [0.5, 0.5])
|
||||
@ -2307,16 +2307,15 @@ class CrosshairROI(ROI):
|
||||
"""A crosshair ROI whose position is at the center of the crosshairs. By default, it is scalable, rotatable and translatable."""
|
||||
|
||||
def __init__(self, pos=None, size=None, **kargs):
|
||||
if size == None:
|
||||
if size is None:
|
||||
size=[1,1]
|
||||
if pos == None:
|
||||
if pos is None:
|
||||
pos = [0,0]
|
||||
self._shape = None
|
||||
ROI.__init__(self, pos, size, **kargs)
|
||||
ROI.__init__(self, pos, size, aspectLocked=True, **kargs)
|
||||
|
||||
self.sigRegionChanged.connect(self.invalidate)
|
||||
self.addScaleRotateHandle(Point(1, 0), Point(0, 0))
|
||||
self.aspectLocked = True
|
||||
|
||||
def invalidate(self):
|
||||
self._shape = None
|
||||
@ -2391,9 +2390,6 @@ class TriangleROI(ROI):
|
||||
"""
|
||||
|
||||
def __init__(self, pos, size, **args):
|
||||
ROI.__init__(self, pos, [size, size], **args)
|
||||
self.aspectLocked = True
|
||||
angles = np.linspace(0, pi * 4 / 3, 3)
|
||||
ROI.__init__(self, pos, [size, size], aspectLocked=True, **args)
|
||||
angles = np.linspace(0, np.pi * 4 / 3, 3)
|
||||
verticies = (np.array((np.sin(angles), np.cos(angles))).T + 1.0) / 2.0
|
||||
|
@ -1,5 +1,4 @@
|
||||
from math import atan2, pi, degrees
|
||||
|
||||
from math import atan2
|
||||
from ..Qt import QtGui, QtCore
|
||||
from ..Point import Point
|
||||
from .. import functions as fn
|
||||
|
@ -550,7 +550,6 @@ class ViewBox(GraphicsWidget):
|
||||
dy = 1
|
||||
mn -= dy*0.5
|
||||
mx += dy*0.5
|
||||
xpad = 0.0
|
||||
|
||||
# Make sure no nan/inf get through
|
||||
if not math.isfinite(mn) or not math.isfinite(mx):
|
||||
|
@ -12,7 +12,7 @@ Widget used for displaying 2D or 3D data. Features:
|
||||
- ROI plotting
|
||||
- Image normalization through a variety of methods
|
||||
"""
|
||||
import os, sys
|
||||
import os
|
||||
from math import log10
|
||||
import numpy as np
|
||||
|
||||
|
@ -5,7 +5,7 @@ import numpy as np
|
||||
from .. import Vector
|
||||
from .. import functions as fn
|
||||
import warnings
|
||||
from math import cos, sin, tan, degrees, radians
|
||||
from math import cos, sin, tan, radians
|
||||
##Vector = QtGui.QVector3D
|
||||
|
||||
ShareWidget = None
|
||||
|
@ -398,9 +398,6 @@ if __name__ == '__main__':
|
||||
# value at the same time.
|
||||
sh = (1./60.)
|
||||
raise
|
||||
|
||||
|
||||
|
||||
return ap
|
||||
|
||||
def _balance(self):
|
||||
@ -408,8 +405,6 @@ if __name__ == '__main__':
|
||||
light = self.lightMeter
|
||||
sh = self.shutter
|
||||
ap = self.aperture
|
||||
fl = self.flash
|
||||
|
||||
bal = (4.0 / ap) * (sh / (1./60.)) * (iso / 100.) * (2 ** light)
|
||||
return log2(bal)
|
||||
|
||||
|
@ -7,10 +7,7 @@ Distributed under MIT/X11 license. See license.txt for more information.
|
||||
|
||||
from ..Qt import QtCore, QtGui, QtWidgets, QT_LIB
|
||||
from ..Point import Point
|
||||
import sys, os
|
||||
from .FileDialog import FileDialog
|
||||
from ..GraphicsScene import GraphicsScene
|
||||
import numpy as np
|
||||
from .. import functions as fn
|
||||
from .. import debug as debug
|
||||
from .. import getConfigOption
|
||||
|
Loading…
Reference in New Issue
Block a user