-
Notifications
You must be signed in to change notification settings - Fork 1
fix F401 E402, E722, and python2 deprecation issues #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
bdb0649
f887d78
9cd8f21
17df09c
f93dfbd
d6b9119
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,75 +16,32 @@ | |
| import re | ||
| import sys | ||
|
|
||
| import numpy as np | ||
| from traits.etsconfig.api import ETSConfig | ||
|
|
||
| ETSConfig.toolkit = "qt4" | ||
|
|
||
| from diffpy.srxconfutils.tools import module_exists_lower | ||
| from diffpy.srxplanar.selfcalibrate import selfCalibrate | ||
| from diffpy.srxplanar.srxplanar import SrXplanar | ||
| from diffpy.srxplanar.srxplanarconfig import checkMax | ||
| from pyface.api import ImageResource, SplashScreen | ||
| from pyface.api import ImageResource | ||
| from traits.api import ( | ||
| Any, | ||
| Array, | ||
| Bool, | ||
| Button, | ||
| CFloat, | ||
| CInt, | ||
| DelegatesTo, | ||
| Dict, | ||
| Directory, | ||
| Enum, | ||
| Event, | ||
| File, | ||
| Float, | ||
| HasTraits, | ||
| Instance, | ||
| Int, | ||
| List, | ||
| Property, | ||
| Range, | ||
| Str, | ||
| cached_property, | ||
| on_trait_change, | ||
| property_depends_on, | ||
| ) | ||
| from traitsui.api import ( | ||
| Action, | ||
| ArrayEditor, | ||
| ButtonEditor, | ||
| CheckListEditor, | ||
| Controller, | ||
| EnumEditor, | ||
| Group, | ||
| Handler, | ||
| HGroup, | ||
| HistoryEditor, | ||
| ImageEditor, | ||
| InstanceEditor, | ||
| Item, | ||
| RangeEditor, | ||
| Tabbed, | ||
| TableEditor, | ||
| TextEditor, | ||
| TitleEditor, | ||
| VGroup, | ||
| View, | ||
| spring, | ||
| ) | ||
| from traitsui.menu import ( | ||
| CancelButton, | ||
| Menu, | ||
| MenuBar, | ||
| OKButton, | ||
| OKCancelButtons, | ||
| ToolBar, | ||
| ) | ||
| from traits.etsconfig.api import ETSConfig | ||
| from traitsui.api import Group, Handler, HGroup, Item, VGroup, View | ||
| from traitsui.menu import CancelButton, OKButton | ||
|
|
||
| from dpx.srxplanargui.srxconfig import SrXconfig | ||
|
|
||
| ETSConfig.toolkit = "qt" | ||
|
|
||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Change deprecated "qt4" to "qt" |
||
| if module_exists_lower("pyfai"): | ||
| import pyFAI | ||
|
|
||
|
|
@@ -146,7 +103,7 @@ def locatePyFAI(self): | |
| pythonbin = sys.executable | ||
| if sys.platform == "win32": | ||
| pyFAIdir = os.path.join(sys.exec_prefix, "Scripts") | ||
| elif sys.platform == "linux2": | ||
| elif sys.platform.startswith("linux"): | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Change deprecated "linux2" platform check to "linux" |
||
| pyFAIdir = os.path.join(sys.exec_prefix, "bin") | ||
| else: | ||
| pyFAIdir = os.path.join(sys.exec_prefix, "bin") | ||
|
|
@@ -170,11 +127,11 @@ def _pyFAIdirChanged(self): | |
| return | ||
|
|
||
| def callPyFAICalibration(self, image=None, dspacefile=None): | ||
| if image == None: | ||
| if image is None: | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. python2 cond check fix |
||
| image = self.image | ||
| else: | ||
| self.image = image | ||
| if dspacefile == None: | ||
| if dspacefile is None: | ||
| dspacefile = self.dspacefile | ||
| else: | ||
| self.dspacefile = dspacefile | ||
|
|
@@ -206,11 +163,8 @@ def callPyFAICalibration(self, image=None, dspacefile=None): | |
|
|
||
| import subprocess | ||
|
|
||
| try: | ||
| os.environ.pop("QT_API") | ||
| except: | ||
| pass | ||
| subprocess.call(calicmd) | ||
| os.environ.pop("QT_API", None) | ||
| subprocess.run(calicmd, check=True) | ||
|
|
||
| # integrate image | ||
| ponifile = os.path.splitext(str(image))[0] + ".poni" | ||
|
|
@@ -227,7 +181,7 @@ def callPyFAICalibration(self, image=None, dspacefile=None): | |
| return | ||
|
|
||
| def parsePyFAIoutput(self, image=None): | ||
| if image == None: | ||
| if image is None: | ||
| image = self.image | ||
|
|
||
| filename = os.path.splitext(image)[0] + ".xy" | ||
|
|
@@ -256,12 +210,12 @@ def parsePyFAIoutput(self, image=None): | |
|
|
||
| def selfCalibration(self, image=None): | ||
| # self.addfiles.selected[0].fullname | ||
| if image == None: | ||
| if image is None: | ||
| image = self.image | ||
|
|
||
| if os.path.exists(image) and os.path.isfile(image): | ||
| for mode, showresults in zip( | ||
| ["x", "y", "x", "y"], [False, False, False, True] | ||
| ["x", "y", "x", "y"], [False, False, False, True] | ||
| ): | ||
| selfCalibrate( | ||
| self.srx, | ||
|
|
@@ -290,7 +244,8 @@ def calibration(self, image=None, dspacefile=None): | |
| qmaxcali = Float(10.0) | ||
|
|
||
| @on_trait_change( | ||
| "srxconfig.[xpixelsize, ypixelsize, distance, wavelength, xdimension, ydimension]" | ||
| "srxconfig.[xpixelsize, ypixelsize, distance, " | ||
| "wavelength, xdimension, ydimension]" | ||
| ) | ||
| def _qmaxChanged(self): | ||
| tthmax, qmax = checkMax(self.srxconfig) | ||
|
|
@@ -299,10 +254,12 @@ def _qmaxChanged(self): | |
| return | ||
|
|
||
| inst1 = Str( | ||
| "Please install pyFAI and FabIO to use the calibration function (refer to help)." | ||
| "Please install pyFAI and FabIO to use" | ||
| "the calibration function (refer to help)." | ||
| ) | ||
| inst2 = Str( | ||
| "(http://github.com/kif/pyFAI, https://forge.epn-campus.eu/projects/azimuthal/files)" | ||
| "(http://github.com/kif/pyFAI," | ||
| "https://forge.epn-campus.eu/projects/azimuthal/files)" | ||
| ) | ||
| main_View = View( | ||
| # Item('calibrationmode', style='custom', label='Calibration mode'), | ||
|
|
@@ -320,7 +277,8 @@ def _qmaxChanged(self): | |
| show_border=True, | ||
| visible_when='calibrationmode=="calibrant"', | ||
| enabled_when="not missingpyFAI", | ||
| label="Please specify the d-space file and the location of pyFAI executable", | ||
| label="Please specify the d-space file and" | ||
| + " the location of pyFAI executable", | ||
| ), | ||
| HGroup( | ||
| Item( | ||
|
|
@@ -371,7 +329,8 @@ def _qmaxChanged(self): | |
| label="Camera Length(mm)", | ||
| visible_when='configmode == "TEM"', | ||
| ), | ||
| label="Please specify the wavelength and distance between sample and detector:", | ||
| label="Please specify the wavelength and" | ||
| + " distance between sample and detector:", | ||
| show_border=True, | ||
| visible_when='calibrationmode=="self"', | ||
| ), | ||
|
|
@@ -416,7 +375,8 @@ def _qmaxChanged(self): | |
| ), | ||
| ), | ||
| show_border=True, | ||
| label="Plasee specify the dimension of detector and size of pixel:", | ||
| label="Plasee specify the dimension of detector" | ||
| + " and size of pixel:", | ||
| visible_when='calibrationmode=="self"', | ||
| ), | ||
| HGroup( | ||
|
|
@@ -443,8 +403,9 @@ def _qmaxChanged(self): | |
|
|
||
|
|
||
| def findFloat(line): | ||
| temp = re.findall("[-+]?\d*\.\d+|[-+]?\d+", line) | ||
| return map(float, temp) | ||
| """Extract all floats from a string and return them as a list.""" | ||
| pattern = r"[-+]?\d*\.\d+|[-+]?\d+" | ||
| return [float(x) for x in re.findall(pattern, line)] | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete imports that unused