Skip to content
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

Avoid using import * in Python MR and PET demo scripts #1215

Merged
merged 7 commits into from
Oct 26, 2023

Conversation

evgueni-ovtchinnikov
Copy link
Contributor

@evgueni-ovtchinnikov evgueni-ovtchinnikov commented Oct 19, 2023

Changes in this pull request

Currently, we use

exec('from sirf.' + args['--engine'] + ' import *')

to import reconstruction modules (engines) for MR (Gadgetron) and PET (STIR). This practice is not recommended, and raises Codacy complaints.

This PR suggests using importlib function instead, e.g. for MR:

import importlib
mr = importlib.import_module('sirf.' + args['--engine'])
acq_data = mr.AcquisitionData()

Testing performed

The demo scripts run ok on my VM.

Related issues

Checklist before requesting a review

  • I have performed a self-review of my code
  • I have added docstrings/doxygen in line with the guidance in the developer guide
  • I have implemented unit tests that cover any new or modified functionality
  • The code builds and runs on my machine
  • CHANGES.md has been updated with any functionality change

Contribution Notes

Please read and adhere to the contribution guidelines.

Please tick the following:

  • The content of this Pull Request (the Contribution) is intentionally submitted for inclusion in SIRF (the Work) under the terms and conditions of the Apache-2.0 License.

@KrisThielemans
Copy link
Member

great idea.

@evgueni-ovtchinnikov evgueni-ovtchinnikov marked this pull request as ready for review October 25, 2023 12:07
Copy link
Member

@KrisThielemans KrisThielemans left a comment

Choose a reason for hiding this comment

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

looks good. 2 comments/questions.

src/xSTIR/pSTIR/STIR.py Show resolved Hide resolved
examples/Python/PET/acquisition_data.py Outdated Show resolved Hide resolved
@evgueni-ovtchinnikov evgueni-ovtchinnikov merged commit 6052b47 into master Oct 26, 2023
5 of 6 checks passed
@evgueni-ovtchinnikov evgueni-ovtchinnikov deleted the engine-import branch October 26, 2023 12:45
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