Skip to content

Conversation

@stevenhua0320
Copy link
Contributor

@zmx27 Ready for review
The same operation as in #8
-Fix F401 import not used error
-Fix E402 module level not on top level
-Fix E722 bare except issue
-Fix python2 deprecation in code.

Copy link
Collaborator

@zmx27 zmx27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments. Also, it might be a good idea to change the function names to snake case, but you don't have to do that in this PR

try:
os.environ.pop("QT_API")
except:
except ImportWarning:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that os.environ acts like a dictionary where the keys are the names of the environment variables, and the values are their corresponding values. In that case, would it be more suitable to except a KeyError?

@on_trait_change(
"srxconfig.[xpixelsize, ypixelsize, distance, wavelength, xdimension, ydimension]"
"srxconfig.[xpixelsize, ypixelsize, distance,"
"wavelength, xdimension, ydimension]"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might need to add a space either in front of wavelength or at the end of the previous line

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)."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing, I think you're missing a space

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)"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have updated

temp = re.findall("[-+]?\d*\.\d+|[-+]?\d+", line)
return map(float, temp)
pattern = r"[-+]?\d*\.\d+|[-+]?\d+"
return [float(x) for x in re.findall(pattern, line)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old version returns a map object, while your new version returns a list. Have you checked where this function is being used and whether that is acceptable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have checked the context of the function. It wants to use the list property. Since in python2 map is more like a property of list while in py3 it becomes an iterator, we need to change it to list structure.

@stevenhua0320 stevenhua0320 changed the title Fix F401 E402, E722, and python2 deprecation issues chore: resolve python2 deprecation issue Sep 26, 2025
@stevenhua0320
Copy link
Contributor Author

@zmx27 Ready for another review

Copy link
Collaborator

@zmx27 zmx27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment but otherwise looks good to me

),
show_border=True,
label="Plasee specify the dimension of detector and size of pixel:",
label="Plasee specify the dimension of detector"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also fix the spelling here to make your life easier when you manually fix pre-commit errors later

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in the new push, please see the update

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@stevenhua0320
Copy link
Contributor Author

@sbillinge Ready for review

@sbillinge
Copy link
Contributor

This looks good. There are some changes that might affect functionality, not just style/linting. Do we have a way to check that these changes didn't break anything? In principle, @zmx27 has a way of checking this by rebuilding and running the full package. It is a bit more overhead, and less complete, than having tests, but it might be good to tests that these changes dind't break anything. If you can figure out how to get that going please do it. If it is too difficult, we can merge this and figure out later how to make everything work when we have CI working.

@stevenhua0320
Copy link
Contributor Author

@sbillinge I'm afraid we need to check the functionality in CI since srxplanargui has a direct dependency of srxplanar, if we need to check gui package work we must have srxplanar also work. However I think srxplanar is also migrating from py2 to py3, so it might be a good idea to check the functionality behavior after two packages are all done with migration.

@sbillinge
Copy link
Contributor

please check with @zmx27 as I thought we had this working already

@zmx27
Copy link
Collaborator

zmx27 commented Sep 29, 2025

@stevenhua0320 Hi Steven, sorry for the late response. Essentially, the method that we came up with to test that the functionalities of xpdfsuite and all of its sub packages didn't break as we migrate everything is to get a set of data (I have Ni.chi and kapton.chi downloaded from our PDFttp_data repo), run the xpdfsuite package, and then click through a few things in the GUI and look at the produced graphs etc to make sure that none of our code broke anything. I can probably pull the changes that you made in this PR, pip install this version of the srxplanargui package, and then do the test I just mentioned to see if I notice anything that is broken. I will do this on my end and will get back to you on my findings!

@stevenhua0320
Copy link
Contributor Author

@stevenhua0320 Hi Steven, sorry for the late response. Essentially, the method that we came up with to test that the functionalities of xpdfsuite and all of its sub packages didn't break as we migrate everything is to get a set of data (I have Ni.chi and kapton.chi downloaded from our PDFttp_data repo), run the xpdfsuite package, and then click through a few things in the GUI and look at the produced graphs etc to make sure that none of our code broke anything. I can probably pull the changes that you made in this PR, pip install this version of the srxplanargui package, and then do the test I just mentioned to see if I notice anything that is broken. I will do this on my end and will get back to you on my findings!

OK, thanks for your response and if something unusual happens, notify me and I would try to figure out where we break the functionality.

@zmx27
Copy link
Collaborator

zmx27 commented Sep 30, 2025

@sbillinge @stevenhua0320 I just finished doing the test by pip installing the srxplanargui package with the changes made in this PR and then running the xpdfsuite package. All of the graphs appeared as expected, and I didn't notice anything else unusual as I clicked through the rest of the GUI. I believe this PR is ready for merge if everything else looks ok!

@sbillinge sbillinge merged commit ddf464c into diffpy:migration Sep 30, 2025
@sbillinge sbillinge deleted the migration-2 branch September 30, 2025 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants